Add public API for checking unhandled exceptions#5177
Draft
jamescrosswell wants to merge 6 commits intomainfrom
Draft
Add public API for checking unhandled exceptions#5177jamescrosswell wants to merge 6 commits intomainfrom
jamescrosswell wants to merge 6 commits intomainfrom
Conversation
Adds two new public extension methods to SentryEvent: - IsFromUnhandledException(): Checks if event is from any unhandled exception - IsFromTerminalException(): Checks if event is from a terminal (crash-causing) exception This addresses the need to filter events based on whether they're unhandled/terminal, particularly useful in MAUI apps where users want to always capture terminal exceptions even if they match other filters (e.g., network timeouts). The implementation uses extension methods as suggested by @bruno-garcia, providing a clean public API without exposing internal methods. Both methods check Exception.Data and SentryExceptions for the handled/terminal flags. Fixes #2877 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5177 +/- ##
=======================================
Coverage 74.08% 74.08%
=======================================
Files 506 507 +1
Lines 18247 18255 +8
Branches 3564 3568 +4
=======================================
+ Hits 13519 13525 +6
Misses 3858 3858
- Partials 870 872 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…n methods HasUnhandledException() and HasUnhandledNonTerminalException() duplicated the logic in the new public extension methods. Removed the private methods and updated GetExceptionType() to call IsFromUnhandledException() and IsFromTerminalException() directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8fc8368. Configure here.
IsFromUnhandledException() && !IsFromTerminalException() is not equivalent to the original per-exception AND check. When SentryExceptions contains a mix of terminal and non-terminal unhandled exceptions, IsFromTerminalException() returns true (finding the terminal one), incorrectly suppressing the UnhandledNonTerminal result. Restore the private method with its original body. HasUnhandledException() remains replaced by the public IsFromUnhandledException() extension method, which is a true semantic equivalent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…led-exception-api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds two new public extension methods to
SentryEvent:IsFromUnhandledException(): Checks if the event is from any unhandled exceptionIsFromTerminalException(): Checks if the event is from a terminal (crash-causing) exceptionMotivation
Fixes #2877
Users need to filter events in callbacks like
BeforeSendbased on whether exceptions are unhandled/terminal. This is particularly useful in MAUI apps where you might want to filter out common exceptions (like network timeouts) but always capture them if they're terminal.Implementation
Following @bruno-garcia's feedback, this uses extension methods rather than making internal methods public. The methods check both
Exception.Dataflags andSentryExceptionsmechanism properties.Key differences:
Both are well-documented with XML docs and usage examples.
🤖 Generated with Claude Code