You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Andrey Kovalev
7fe2f59f05
|
3 years ago | |
---|---|---|
.. | ||
.codecov.yml | 3 years ago | |
.editorconfig | 3 years ago | |
.gitignore | 3 years ago | |
.golangci.yml | 3 years ago | |
LICENSE | 3 years ago | |
Makefile | 3 years ago | |
PATENTS | 3 years ago | |
README.md | 3 years ago | |
adaptor.go | 3 years ago | |
doc.go | 3 years ago | |
errors.go | 3 years ago | |
format.go | 3 years ago | |
frame.go | 3 years ago | |
go.coverage.sh | 3 years ago | |
go.test.sh | 3 years ago | |
noerrtrace.go | 3 years ago | |
trace.go | 3 years ago | |
wrap.go | 3 years ago |
README.md
errors
Fork of xerrors with explicit Wrap instead of %w
.
Clear is better than clever.
go get github.com/go-faster/errors
if err != nil {
return errors.Wrap(err, "something went wrong")
}
Why
- 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
Don't need traces?
Call errors.DisableTrace
or use build tag noerrtrace
.
Migration
go get github.com/go-faster/errors/cmd/gowrapper@latest
gowrapper ./...
License
BSD-3-Clause, same as Go sources