chore: log warning instead of error and log additional details if web socket exception occurred

This commit is contained in:
Stevan Freeborn
2025-06-16 11:01:59 -05:00
parent fc73614c7c
commit ad3cda2b77
@@ -224,7 +224,17 @@ internal sealed class DiscordGatewayClient : IDiscordGatewayClient
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
_logger.LogError(ex, "Unexpected error while receiving messages");
_logger.LogWarning(ex, "Unexpected error while receiving messages");
if (ex is WebSocketException wse)
{
_logger.LogWarning(
"WebSocket error: {Message} - {ErrorCode} - {WebSocketErrorCode}",
wse.Message,
wse.ErrorCode,
wse.WebSocketErrorCode
);
}
_logger.LogWarning("Closing connection and invalidating session.");