hermes-client/Seven/Socket/Handlers/ErrorHandler.cs

30 lines
852 B
C#
Raw Normal View History

using CommonSocketLibrary.Abstract;
using CommonSocketLibrary.Common;
using Serilog;
using TwitchChatTTS.Seven.Socket.Data;
namespace TwitchChatTTS.Seven.Socket.Handlers
{
public class ErrorHandler : IWebSocketHandler
{
private readonly ILogger _logger;
public int OperationCode { get; } = 6;
public ErrorHandler(ILogger logger)
{
_logger = logger;
}
2024-12-28 16:19:28 -05:00
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
{
if (data is not ErrorMessage message || message == null)
2024-12-28 16:19:28 -05:00
return Task.CompletedTask;
if (message.Exception != null)
_logger.Error(message.Exception, message.Message);
else
_logger.Error(message.Message);
return Task.CompletedTask;
}
}
}