Skip to content

Commit

Permalink
Add try catch with logging
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Feb 12, 2020
1 parent baf35c0 commit 94303e4
Showing 1 changed file with 51 additions and 49 deletions.
100 changes: 51 additions & 49 deletions src/Lurker/ClientLurker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,64 +333,66 @@ private void OnFileChanged(string newline)
return;
}

// TradeEvent need to be parse before whisper
var tradeEvent = TradeEvent.TryParse(newline);
if (tradeEvent != null)
try
{
Logger.Debug($"Parsed: {newline}");
this.NewOffer?.Invoke(this, tradeEvent);
return;
}
// TradeEvent need to be parse before whisper
var tradeEvent = TradeEvent.TryParse(newline);
if (tradeEvent != null)
{
this.NewOffer?.Invoke(this, tradeEvent);
return;
}

var whisperEvent = WhisperEvent.TryParse(newline);
if (whisperEvent != null)
{
Logger.Debug($"Parsed: {newline}");
this.Whispered?.Invoke(this, whisperEvent);
return;
}
var whisperEvent = WhisperEvent.TryParse(newline);
if (whisperEvent != null)
{
this.Whispered?.Invoke(this, whisperEvent);
return;
}

var locationEvent = LocationChangedEvent.TryParse(newline);
if (locationEvent != null)
{
Logger.Debug($"Parsed: {newline}");
this.LocationChanged?.Invoke(this, locationEvent);
return;
}
var locationEvent = LocationChangedEvent.TryParse(newline);
if (locationEvent != null)
{
this.LocationChanged?.Invoke(this, locationEvent);
return;
}

var tradeAcceptedEvent = TradeAcceptedEvent.TryParse(newline);
if (tradeAcceptedEvent != null)
{
Logger.Debug($"Parsed: {newline}");
this.TradeAccepted?.Invoke(this, tradeAcceptedEvent);
return;
}
var tradeAcceptedEvent = TradeAcceptedEvent.TryParse(newline);
if (tradeAcceptedEvent != null)
{
this.TradeAccepted?.Invoke(this, tradeAcceptedEvent);
return;
}

var monsterEvent = MonstersRemainEvent.TryParse(newline);
if (monsterEvent != null)
{
Logger.Debug($"Parsed: {newline}");
this.RemainingMonsters?.Invoke(this, monsterEvent);
return;
}
var monsterEvent = MonstersRemainEvent.TryParse(newline);
if (monsterEvent != null)
{
this.RemainingMonsters?.Invoke(this, monsterEvent);
return;
}

var playerJoinEvent = PlayerJoinedEvent.TryParse(newline);
if (playerJoinEvent != null)
{
Logger.Debug($"Parsed: {newline}");
this.PlayerJoined?.Invoke(this, playerJoinEvent);
return;
}
var playerJoinEvent = PlayerJoinedEvent.TryParse(newline);
if (playerJoinEvent != null)
{
this.PlayerJoined?.Invoke(this, playerJoinEvent);
return;
}

var playerLeftEvent = PlayerLeftEvent.TryParse(newline);
if (playerLeftEvent != null)
{

this.PlayerLeft?.Invoke(this, playerLeftEvent);
return;
}

var playerLeftEvent = PlayerLeftEvent.TryParse(newline);
if (playerLeftEvent != null)
Logger.Trace($"Not parsed: {newline}");
}
catch (Exception ex)
{
Logger.Debug($"Parsed: {newline}");
this.PlayerLeft?.Invoke(this, playerLeftEvent);
return;
Logger.Debug($"Line in error: {newline}");
Logger.Error(ex, ex.Message);
}

Logger.Trace($"Not parsed: {newline}");
}

/// <summary>
Expand Down

0 comments on commit 94303e4

Please sign in to comment.