Skip to content

tdakkota/errors

 
 

Repository files navigation

errors Go Reference codecov

Fork of xerrors with explicit Wrap instead of %w.

Clear is better than clever.

go get github.com/go-faster/errors
errors.Wrap(err, "message")

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

About

clear go error wrapping with caller

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.9%
  • Other 1.1%