Cleaned up websocket exceptions

This commit is contained in:
RogueException
2015-12-25 19:38:53 -04:00
parent 503d474135
commit 31bea1a394

View File

@@ -83,7 +83,13 @@ namespace Discord.Net.WebSockets
{
Exception ex;
if (e is ClosedEventArgs)
ex = new Exception($"Received close code {(e as ClosedEventArgs).Code}: {(e as ClosedEventArgs).Reason ?? "No reason"}");
{
int code = (e as ClosedEventArgs).Code;
string reason = (e as ClosedEventArgs).Reason;
if (String.IsNullOrEmpty(reason))
reason = "No reason";
ex = new Exception($"Received close code {code}: {reason}");
}
else
ex = new Exception($"Connection lost");
_taskManager.SignalError(ex, isUnexpected: true);