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

fix: Report usage error including stack trace #189

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

rhcarvalho
Copy link
Contributor

Prior to this, calling CaptureException, Recover or RecoverWithContext with a nil error would send a message event to Sentry without a stack trace.

Looking at the Sentry issues list, and issue detail, all you see is "Called CaptureException with nil value" without a clue of what caused it.

This change turns that message into a sentry.usageError (new type) with a stack trace, making it easier to understand what is wrong and fix user code.

BEFORE

No stacktrace nor any clue where the incorrect call to CaptureException is.

image
image

AFTER

Usage error with description and file name and line number information, plus source code context when available.

image
image

Without source context:

image

event.Level = level
event.Message = fmt.Sprintf("Called %s with nil value", callerFunctionName())
return event
exception = usageError{fmt.Errorf("%s called with nil error", callerFunctionName())}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the function name to the very beginning because it is the most relevant information.

@rhcarvalho rhcarvalho requested a review from kamilogorek April 3, 2020 17:21
Prior to this, calling CaptureException, Recover or RecoverWithContext
with a nil error would send a message event to Sentry without a stack
trace.

Looking at the Sentry issues list, and issue detail, all you see is
"Called CaptureException with nil value" without a clue of what caused
it.

This commit turns that message into a sentry.usageError with a stack
trace, making it easier to understand what is wrong and fix user code.
Copy link
Contributor

@kamilogorek kamilogorek left a comment

Choose a reason for hiding this comment

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

👌

@rhcarvalho rhcarvalho merged commit 87c79e3 into getsentry:master Apr 3, 2020
@rhcarvalho rhcarvalho deleted the usage-error branch April 3, 2020 21:45
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.

2 participants