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

Always attach a stack trace, when AttachStackTrace is true #2262

Closed
mattjohnsonpint opened this issue Mar 28, 2023 · 0 comments · Fixed by #2266
Closed

Always attach a stack trace, when AttachStackTrace is true #2262

mattjohnsonpint opened this issue Mar 28, 2023 · 0 comments · Fixed by #2266
Labels
Feature New feature or request

Comments

@mattjohnsonpint
Copy link
Contributor

mattjohnsonpint commented Mar 28, 2023

Problem Statement

The current behavior SentryOptions.AttachStackTrace = true is that we attach a stack trace when capturing any error event that does not contain an exception.

This does not cover the case where there is an exception on the event, but it does not contain a stack trace.

For example:

SentrySdk.CaptureException(new Exception("test"));

Regardless of the AttachStackTrace option, no stack trace will be sent.

Solution Brainstorm

AttachStackTrace = true implies that there should always be a stack trace. Thus, we can check the exceptions on the event and see if any of them have a stack trace. If none do, then attach one separately.

Note that the stack trace will point at where the exception is captured, not where it is created.

In other words, it's different than throwing and capturing the exception like this:

try
{
    throw new Exception("test");
}
catch (Exception exception)
{
    SentrySdk.CaptureException(exception);
}

In that case, the stack trace will point at where the exception is thrown.

Still, it's better to have some stack trace than nothing, IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
Archived in project
1 participant