Skip to content

Commit

Permalink
Change UnobservedTaskException from being marked as Unhandled to Unob…
Browse files Browse the repository at this point in the history
…served
  • Loading branch information
ProRedCat committed Nov 5, 2024
1 parent 10ef9d1 commit da00bdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Mindscape.Raygun4Net.NetCore.Common/RaygunClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ public virtual bool CatchUnhandledExceptions
set => _settings.CatchUnhandledExceptions = value;
}

private void OnApplicationUnhandledException(Exception exception, bool isTerminating)
private void OnApplicationUnhandledException(Exception exception, bool isTerminating, string tag)
{
if (!_settings.CatchUnhandledExceptions)
{
return;
}

Send(exception, UnhandledExceptionTags);
Send(exception, new List<string> { tag });
}

protected RaygunClientBase(RaygunSettingsBase settings)
Expand Down Expand Up @@ -339,7 +339,7 @@ public async Task SendAsync(Exception exception)
{
await SendAsync(exception, null, null).ConfigureAwait(false);
}

/// <summary>
/// Transmits an exception to Raygun asynchronously.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Mindscape.Raygun4Net.NetCore.Common/UnhandledExceptionBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Mindscape.Raygun4Net
{
public static class UnhandledExceptionBridge
{
internal delegate void UnhandledExceptionHandler(Exception exception, bool isTerminating);
internal delegate void UnhandledExceptionHandler(Exception exception, bool isTerminating, string tag);

private static readonly List<WeakExceptionHandler> Handlers = new List<WeakExceptionHandler>();

Expand All @@ -23,22 +23,22 @@ static UnhandledExceptionBridge()
RaiseUnhandledException(args.ExceptionObject as Exception, args.IsTerminating);
};

TaskScheduler.UnobservedTaskException += (sender, args) => { RaiseUnhandledException(args.Exception, false); };
TaskScheduler.UnobservedTaskException += (sender, args) => { RaiseUnhandledException(args.Exception,false, "UnobservedTaskException"); };

// Try attach platform specific exceptions
WindowsPlatform.TryAttachExceptionHandlers();
AndroidPlatform.TryAttachExceptionHandlers();
ApplePlatform.TryAttachExceptionHandlers();
}

public static void RaiseUnhandledException(Exception exception, bool isTerminating)
public static void RaiseUnhandledException(Exception exception, bool isTerminating, string tag = "UnhandledException")
{
HandlersLock.EnterReadLock();
try
{
foreach (var handler in Handlers)
{
handler.Invoke(exception, isTerminating);
handler.Invoke(exception, isTerminating, tag);
}
}
finally
Expand Down Expand Up @@ -82,15 +82,15 @@ public WeakExceptionHandler(UnhandledExceptionHandler handler)
_reference = new WeakReference<UnhandledExceptionHandler>(handler);
}

public void Invoke(Exception exception, bool isTerminating)
public void Invoke(Exception exception, bool isTerminating, string tag)
{
// If the target is dead then do nothing
if (!_reference.TryGetTarget(out var handle))
{
return;
}

handle.Invoke(exception, isTerminating);
handle.Invoke(exception, isTerminating, tag);
}
}
}
Expand Down

0 comments on commit da00bdc

Please sign in to comment.