Package errors provides error wrapping with stack trace and human-readable operations.
- Stacked human-readable operations associated with errors
- Customizable error kinds and codes with checking
- Error list aka multi-error
- Error group to aggregate errors from goroutines in a list
- Stack trace capture
go get -u github.com/w1ck3dg0ph3r/go-errors
package mypackage
import "github.com/w1ck3dg0ph3r/go-errors"
func MyFunc() error {
const op = errors.Op("mypackage.MyFunc")
if err := DoSmth(); err != nil {
if errors.IsAnyOf(err, errors.Transient, errors.Deadlock) {
// TODO: retry
}
LogError(err.Error(), errors.Ops(err), errors.Trace(err))
return errors.E(op, "can't do smth", err)
}
return nil
}
Any contributions are welcome in a form of issues and pull requests.