Skip to content

objenious/errors

 
 

Repository files navigation

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

Packages

No packages published

Languages

  • Go 97.4%
  • Makefile 2.6%