Merge pull request #6 from StevanFreeborn/stevanfreeborn/chore/modify-logging

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 09:03:15 -07:00
committed by GitHub
@@ -224,7 +224,17 @@ internal sealed class DiscordGatewayClient : IDiscordGatewayClient
catch (Exception ex) catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types #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."); _logger.LogWarning("Closing connection and invalidating session.");