Add exception for webhook + add gracefull time before market decrease

This commit is contained in:
2025-11-05 10:54:14 +07:00
parent 43aa62fcb3
commit 1079f38ed7
3 changed files with 15 additions and 6 deletions

View File

@@ -22,11 +22,11 @@ public class WebhookService : IWebhookService
_configuration = configuration;
_logger = logger;
_n8nWebhookUrl = _configuration["N8n:WebhookUrl"] ?? string.Empty;
// Configure basic authentication if credentials are provided
var username = _configuration["N8n:Username"];
var password = _configuration["N8n:Password"];
if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
@@ -63,12 +63,12 @@ public class WebhookService : IWebhookService
}
else
{
_logger.LogWarning($"Failed to send webhook notification. Status: {response.StatusCode}");
throw new Exception($"Failed to send webhook message. Status: {response.StatusCode}");
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error sending webhook notification");
SentrySdk.CaptureException(ex);
}
}
@@ -100,12 +100,12 @@ public class WebhookService : IWebhookService
}
else
{
_logger.LogWarning($"Failed to send webhook message. Status: {response.StatusCode}");
throw new Exception($"Failed to send webhook message. Status: {response.StatusCode}");
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error sending webhook message");
SentrySdk.CaptureException(ex);
}
}
}