Fork of xerrors with Wrap
and Wrapf
instead of %w
parsing.
Clear is better than clever.
go get github.com/ogen-go/errors
if err != nil {
return errors.Wrap(err, "something went wrong")
}
- Using
Wrap
is the most explicit way to wrap errors - Wrapping with
fmt.Errorf("foo: %w", err)
is implicit, redundant and error-prone - Parsing
"foo: %w"
is implicit, redundant and slow - The pkg/errors and xerrrors are not maintainted
- The cockroachdb/errors is too big
- The
errors
has no caller stack trace
Call errors.DisableTrace
or use build tag noerrtrace
.