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

Recover and RecoverWithContext with arbitrary types #268

Merged
merged 5 commits into from Jul 21, 2020

Conversation

rhcarvalho
Copy link
Contributor

Fixes #219.

While Client.Recover and Client.RecoverWithContext are mostly meant to
be internal methods called by methods with the same name on Hub, they
are part of the exported API on Client.

This commit avoids a runtime panic when those methods are called with a
nil *EventHint.
client.go Outdated Show resolved Hide resolved
This eliminates some code duplication.

Note that it is important to keep the call to recover in the body of the
function itself, because the Go spec defines that the return value of
recover is (always) nil if it was not called directly by a deferred
function.
The previous behavior was to silently stop panics without reporting to
Sentry when the return value from recover() was not an error or a
string.

Runtime panics are specified to implement the predefined error
interface, and string is probably the second most common type passed to
panic() calls, still calls like panic(42) should not pass silently.

This fix converts any other type to string using Go's standard
formatting rules and reports the message to Sentry.
@rhcarvalho rhcarvalho merged commit d7e26d5 into getsentry:master Jul 21, 2020
@rhcarvalho rhcarvalho deleted the recover-arbitrary-types branch July 21, 2020 11:01
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.

Recover and RecoverWithContext with arbitrary types
2 participants