Skip to content

Commit

Permalink
Ignore additional exception types in Sentry
Browse files Browse the repository at this point in the history
Additional types of exceptions ignored include UnauthorizedAccessException, HttpRequestException, and WebException (some conditions on this). Furthermore, AniDBBannedException has been marked with SentryIgnore attribute.
  • Loading branch information
Cazzar committed Jan 20, 2024
1 parent 3295839 commit c2ef220
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Shoko.Server/Providers/AniDB/AniDBBannedException.cs
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
13 changes: 13 additions & 0 deletions Shoko.Server/Services/ErrorHandling/SentryInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using NLog;
using Sentry;
Expand Down Expand Up @@ -83,6 +84,18 @@ private void Init(string environment, Dictionary<string, string> extraInfo)
if (arg.Exception is DirectoryNotFoundException)
return null;

if (arg.Exception is UnauthorizedAccessException)
return null;

if (arg.Exception is HttpRequestException)

Check failure on line 90 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Standalone linux-x64 (Daily)

The type or namespace name 'HttpRequestException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 90 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Framework linux-x64 (Daily)

The type or namespace name 'HttpRequestException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 90 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Standalone linux-arm64 (Daily)

The type or namespace name 'HttpRequestException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 90 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build Tray Service Standalone (Daily)

The type or namespace name 'HttpRequestException' could not be found (are you missing a using directive or an assembly reference?)
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)

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Standalone linux-x64 (Daily)

A local variable or function named 'ex' is already defined in this scope

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Standalone linux-x64 (Daily)

Use of unassigned local variable 'ex'

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Framework linux-x64 (Daily)

A local variable or function named 'ex' is already defined in this scope

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Framework linux-x64 (Daily)

Use of unassigned local variable 'ex'

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Standalone linux-arm64 (Daily)

A local variable or function named 'ex' is already defined in this scope

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build CLI — Standalone linux-arm64 (Daily)

Use of unassigned local variable 'ex'

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build Tray Service Standalone (Daily)

A local variable or function named 'ex' is already defined in this scope

Check failure on line 96 in Shoko.Server/Services/ErrorHandling/SentryInit.cs

View workflow job for this annotation

GitHub Actions / Build Tray Service Standalone (Daily)

Use of unassigned local variable 'ex'
return null;

if (arg.Exception?.GetType().GetCustomAttribute<SentryIgnoreAttribute>() is not null)
return null;

Expand Down

0 comments on commit c2ef220

Please sign in to comment.