In Event.SetException support errors implementing Unwrap() []error #1045
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.
Background
At some point in time Go grew types of errors that do not support the standard
errors.Unwrap()
function. Notablyerrors.Join(...)
andfmt.Errorf("%w: multiple errors here %w", err1, err2)
. These errors expose an interfaceUnwrap() []error
. This is also described in the Go documentation: https://pkg.go.dev/errors#UnwrapThis new Unwrap interface is not supported in the Sentry client, leading to not picking up stacktraces correctly for errors that have been wrapped this way.
Description
In this PR I update
Event.SetException
to support these new "multi-errors".It is done by implementing a Go-1.23-style iterator
unwrapAll(err)
. The code does currently not use range-over-func so requires no bump in Go dependency; but is ready for that when the language level is bumped one day.