-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Errors are not always wrapped where the underlying cause is available via Unwrap -- this is common to avoid implementation detail leakages across API boundaries, to avoid callers depending on specific internal errors via errors.Is or errors.As.
However, this also loses any traces from the underlying errors, and traces aren't intended for APIs but debuggability. This is pretty common when Errorf is used with %v instead of %w. Ideally, we'd have some way to maintain the trace in these cases.
Example API to start the discussion:
if err := [...]; err != nil {
return WithTrace(err).Errorf("foo: %v", err)
}or
err := [...]
if errors.Is(err, fs.ErrNotExist) {
return WithTrace(err).Wrap(errUserNotFound)
}From an API perspective, we should avoid an API that takes 2 error arguments where one's used for the underlying trace, and the other is the returned error, as it's too easy to mixup the arguments.
Metadata
Metadata
Assignees
Labels
No labels