Skip to content

Allow SDK users to control Mechanism.Handled for captured exceptions #3383

Description

@bitsandfoxes

Tip

tldr; see #3383 (comment)

The MainExceptionProcessor handles setting the mechanism here:

else if (exception.StackTrace != null)
{
// The exception was thrown, but it was caught by the user, not an integration.
// Thus, we can mark it as handled.
mechanism.Handled = true;
}
else
{
// The exception was never thrown. It was just constructed and then captured.
// Thus, it is neither handled nor unhandled.
mechanism.Handled = null;
}

So this code ends up with Handled = true

try
{
    throw new Exception();
}
catch (Exception ex)
{
    // will be marked as handled 
    SentrySdk.CaptureException(ex);
}

And this code ends up with Handled -- in the issue's Highlights

// will not be marked as anything
SentrySdk.CaptureException(new Exception());

Screenshot 2024-05-23 at 13 32 53

Interestingly, captured messages are Handled -- too.

Which, personally, I find confusing. If an exception is not unhandled, should we not consider it handled implicitly? I'm not talking technical correctness here but user expectations.

But I can still filter issues based on error.handled:false so maybe it doesn't matter?

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Done
    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions