You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
err:= [...]
if errors.Is(err, fs.ErrNotExist) {
returnWithTrace(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.
The text was updated successfully, but these errors were encountered:
If we do something like this, we'll may want to define a cross-repo interface contract for extracting trace information (similar to pkg/errors' interface{ Stacktrace() errors.StackTrace }) from an error.
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 viaerrors.Is
orerrors.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:
or
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.
The text was updated successfully, but these errors were encountered: