diff --git a/SynoAI/Notifiers/Webhook/Webhook.cs b/SynoAI/Notifiers/Webhook/Webhook.cs index 403fb1f..f83a6a6 100644 --- a/SynoAI/Notifiers/Webhook/Webhook.cs +++ b/SynoAI/Notifiers/Webhook/Webhook.cs @@ -118,26 +118,34 @@ public override async Task SendAsync(Camera camera, Notification notification, I logger.LogInformation($"{camera.Name}: Webhook: Calling {Method}."); HttpResponseMessage response; - switch (Method) + try { - case "DELETE": - response = await client.DeleteAsync(Url); - break; - case "GET": - response = await client.GetAsync(Url); - break; - case "PATCH": - response = await client.PatchAsync(Url, content); - break; - case "POST": - response = await client.PostAsync(Url, content); - break; - case "PUT": - response = await client.PutAsync(Url, content); - break; - default: - logger.LogError($"{camera.Name}: Webhook: The method type '{Method}' is not supported."); - return; + switch (Method) + { + case "DELETE": + response = await client.DeleteAsync(Url); + break; + case "GET": + response = await client.GetAsync(Url); + break; + case "PATCH": + response = await client.PatchAsync(Url, content); + break; + case "POST": + response = await client.PostAsync(Url, content); + break; + case "PUT": + response = await client.PutAsync(Url, content); + break; + default: + logger.LogError($"{camera.Name}: Webhook: The method type '{Method}' is not supported."); + return; + } + } + catch (Exception ex) + { + logger.LogError($"{camera.Name}: Webhook: Unhandled Exception occurred '{ex.Message}'."); + return; } if (response.IsSuccessStatusCode)