From f836b39da0edfa4e28c5ea0b593172f06e3292ed Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Tue, 21 Aug 2018 12:41:03 -0500 Subject: [PATCH] don't email for deployment-interrupted snapshot exceptions --- src/FilterLists.Services/Snapshot/Snapshot.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/FilterLists.Services/Snapshot/Snapshot.cs b/src/FilterLists.Services/Snapshot/Snapshot.cs index f9cdc0da3..45f935635 100644 --- a/src/FilterLists.Services/Snapshot/Snapshot.cs +++ b/src/FilterLists.Services/Snapshot/Snapshot.cs @@ -182,16 +182,22 @@ private async Task TrackException(Exception e) private async Task SendExceptionEmail(Exception e) { - var msg = new StringBuilder(); - msg.AppendLine("FilterListId: " + list.Id); - msg.AppendLine("Exception:"); - msg.AppendLine(e.Message); - msg.AppendLine(e.StackTrace); - msg.AppendLine(e.InnerException?.Message); - msg.AppendLine(e.InnerException?.StackTrace); - await emailService.SendEmailAsync("Snapshot Exception", msg.ToString()); + if (!IsDeploymentInterrupted(e)) + { + var msg = new StringBuilder(); + msg.AppendLine("FilterListId: " + list.Id); + msg.AppendLine("Exception:"); + msg.AppendLine(e.Message); + msg.AppendLine(e.StackTrace); + msg.AppendLine(e.InnerException?.Message); + msg.AppendLine(e.InnerException?.StackTrace); + await emailService.SendEmailAsync("Snapshot Exception", msg.ToString()); + } } + private static bool IsDeploymentInterrupted(Exception e) => + e.Message.Contains("Failed to read the result set."); + private void TrackExceptionInApplicationInsights(Exception e) { telemetryClient.TrackException(e);