Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 1.52 KB

README.md

File metadata and controls

30 lines (21 loc) · 1.52 KB

errors for go 1.13 and beyond Travis-CI AppVeyor GoDoc Report card Sourcegraph

Package errors provides simple error handling primitives, compatible with Go 1.13 error wrapping.

go get github.com/objenious/errors

The traditional error handling idiom in Go is roughly akin to

if err != nil {
        return err
}

which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error.

Adding context to an error

The errors.Wrap function returns a new error that adds context to the original error. For example

_, err := ioutil.ReadAll(r)
if err != nil {
        return errors.Wrap(err, "read failed")
}

Read the package documentation for more information.

License

BSD-2-Clause