Skip to content

Commit

Permalink
Preciser error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Aug 8, 2019
1 parent 0dea206 commit e1a8eb8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Libplanet/Net/Swarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,11 +1944,11 @@ private void ReceiveMessage(object sender, NetMQSocketEventArgs e)
NetMQMessage raw = e.Socket.ReceiveMultipartMessage();

_logger.Verbose(
"The raw message[frame count: {0}] has received.",
"A raw message [frame count: {0}] has received.",
raw.FrameCount
);
Message message = Message.Parse(raw, reply: false);
_logger.Debug($"The message[{message}] has parsed.");
_logger.Debug($"A message has parsed: {0}", message);

// it's still async because some method it relies are async yet.
Task.Run(
Expand All @@ -1960,19 +1960,27 @@ private void ReceiveMessage(object sender, NetMQSocketEventArgs e)
}
catch (Exception exc)
{
_logger.Error("Something went wrong during message parsing: {0}", exc);
_logger.Error(
exc,
"Something went wrong during message parsing: {0}",
exc
);
throw;
}
},
_cancellationToken);
}
catch (InvalidMessageException ex)
{
_logger.Error(ex, "Could not parse NetMQMessage properly; ignore.");
_logger.Error(ex, "Could not parse NetMQMessage properly; ignore: {0}", ex);
}
catch (Exception ex)
{
_logger.Error(ex, "An unexpected exception occured during ReceiveMessage().");
_logger.Error(
ex,
"An unexpected exception occured during ReceiveMessage(): {0}",
ex
);
}
}

Expand Down

0 comments on commit e1a8eb8

Please sign in to comment.