From c2ef220ec23fa4ec9eef1839d6bd73483a181eae Mon Sep 17 00:00:00 2001 From: Cazzar Date: Sun, 21 Jan 2024 02:42:22 +1100 Subject: [PATCH] Ignore additional exception types in Sentry Additional types of exceptions ignored include UnauthorizedAccessException, HttpRequestException, and WebException (some conditions on this). Furthermore, AniDBBannedException has been marked with SentryIgnore attribute. --- .../Providers/AniDB/AniDBBannedException.cs | 3 ++- Shoko.Server/Services/ErrorHandling/SentryInit.cs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Shoko.Server/Providers/AniDB/AniDBBannedException.cs b/Shoko.Server/Providers/AniDB/AniDBBannedException.cs index 322e09472..be489d383 100644 --- a/Shoko.Server/Providers/AniDB/AniDBBannedException.cs +++ b/Shoko.Server/Providers/AniDB/AniDBBannedException.cs @@ -1,8 +1,9 @@ using System; +using Shoko.Server.Services.ErrorHandling; namespace Shoko.Server.Providers.AniDB; -[Serializable] +[Serializable, SentryIgnore] public class AniDBBannedException : Exception { public UpdateType BanType { get; set; } diff --git a/Shoko.Server/Services/ErrorHandling/SentryInit.cs b/Shoko.Server/Services/ErrorHandling/SentryInit.cs index f8455c132..55ffc2b89 100644 --- a/Shoko.Server/Services/ErrorHandling/SentryInit.cs +++ b/Shoko.Server/Services/ErrorHandling/SentryInit.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Net; using System.Reflection; using NLog; using Sentry; @@ -83,6 +84,18 @@ private void Init(string environment, Dictionary extraInfo) if (arg.Exception is DirectoryNotFoundException) return null; + if (arg.Exception is UnauthorizedAccessException) + return null; + + if (arg.Exception is HttpRequestException) + return null; + + if (arg.Exception is WebException ex && ex.Response is HttpWebResponse resp && resp.StatusCode == HttpStatusCode.NotFound) + return null; + + if (arg.Exception is WebException ex && ex.Status == WebExceptionStatus.ConnectFailure) + return null; + if (arg.Exception?.GetType().GetCustomAttribute() is not null) return null;