Added a few null checks

This commit is contained in:
RogueException
2015-10-06 23:51:06 -03:00
parent 5f494b89d0
commit 90e8d5994d

View File

@@ -122,6 +122,9 @@ namespace Discord
//Connection //Connection
public async Task<string> Connect(string gateway, string token) public async Task<string> Connect(string gateway, string token)
{ {
if (gateway == null) throw new ArgumentNullException(nameof(gateway));
if (token == null) throw new ArgumentNullException(nameof(token));
try try
{ {
_state = (int)DiscordClientState.Connecting; _state = (int)DiscordClientState.Connecting;
@@ -283,8 +286,9 @@ namespace Discord
try { action(); } try { action(); }
catch (Exception ex) catch (Exception ex)
{ {
var ex2 = ex.GetBaseException();
RaiseOnLog(LogMessageSeverity.Error, LogMessageSource.Client, RaiseOnLog(LogMessageSeverity.Error, LogMessageSource.Client,
$"{name} event handler raised an exception: ${ex.GetBaseException().Message}"); $"{name}'s handler raised {ex2.GetType().Name}: ${ex2.Message}");
} }
} }