DeSinc / SallyBot

AI Chatbot coded in Discord.net C#
MIT License
299 stars 51 forks source link

Task Client_Log can't handle Discord.Net.Websocket exceptions #18

Closed lordib closed 1 year ago

lordib commented 1 year ago

When exception Discord.Websocket.GatewayReconnectException occurs Client_Log tries to apply a ToString() method to a Msg.Message field which turns out to be null at the moment of error. As a result System.NullReferenceException is trown. The actual log message during Discord.Net.Websocket exception could be obtained with Msg.Exception.Message. That way System.NullReferenceException here could be evaded.

ErnestoTheGamer commented 1 year ago

Just want to state that I experience the same behaviour.

DeSinc commented 1 year ago

Fixed this by checking Msg.Message != null first, then if it is, next check if Msg.Exception is != null too, then if there is an exception write that. Otherwise just do nothing at all.