diff --git a/backend/api/EventHandlers/TeamsMessageEventHandler.cs b/backend/api/EventHandlers/TeamsMessageEventHandler.cs index ad760c3de..04c085ac5 100644 --- a/backend/api/EventHandlers/TeamsMessageEventHandler.cs +++ b/backend/api/EventHandlers/TeamsMessageEventHandler.cs @@ -47,8 +47,16 @@ private async void OnTeamsMessageReceived(object? sender, TeamsMessageEventArgs client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var content = CreateTeamsMessageCard(e.TeamsMessage); - - var response = await client.PostAsync(url, content); + HttpResponseMessage? response; + try + { + response = await client.PostAsync(url, content); + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to send message to Teams"); + return; + } if (response.IsSuccessStatusCode) { _logger.LogInformation("Post request via teams incomming webhook was successful, Status Code: {response.StatusCode}", response.StatusCode); @@ -74,4 +82,3 @@ private static StringContent CreateTeamsMessageCard(string message) } } } -