Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change UnobservedTaskException from being tagged as UnhandledException to UnobservedTaskException #548

Merged
merged 5 commits into from
Nov 12, 2024

Conversation

ProRedCat
Copy link
Contributor

No description provided.

Copy link
Contributor

@QuantumNightmare QuantumNightmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments to consider

{
if (!_settings.CatchUnhandledExceptions)
{
return;
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the constant UnhandledExceptionTags is no longer used because of this change and so should be deleted too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had that in mind, kept it in case we needed it but likely we do not anymore

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this class is not intended to be used by customers, but this is technically a breaking change due to it being public. (Same as all the public methods above). Shall we instead make an overload for this method and change the other methods above to not have a tag passed in (if that argument is never used) and just pass the string literal from with their method bodies?

Copy link
Contributor Author

@ProRedCat ProRedCat Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be addressed now, let me know what you think

Edit: That class is private, so that contract doesn't matter. I added the compatibility to the UnhandledExceptionBridge class

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I didn't see this code is in a nested private class

@@ -23,22 +24,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"); };
Copy link

@velocitysystems velocitysystems Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ProRedCat I believe UnobservedTaskException may always (or nearly always) raise an AggregateException. If there is only one inner exception this should really be unboxed. This appears to be the current behavior of the MAUI Xamarin provider.

Copy link

@velocitysystems velocitysystems Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good @ProRedCat. What about AggregateException's which are not unobserved task exceptions (handled + unhandled) - Will they be unwrapped elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case right now it's only the UnobservedTaskExceptions, will have a chat with some other around handled + unhandled

Copy link
Contributor Author

@ProRedCat ProRedCat Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observability for others: We do have a feature for automatically unwrapping exceptions in our .NET Core provider.

This is done through _raygunClient.AddWrapperExceptions(typeof(AggregateException))

Copy link
Contributor

@QuantumNightmare QuantumNightmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes

@ProRedCat ProRedCat merged commit 50c3706 into master Nov 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants