Support errors.As and errors.Is (#28)

Go 1.13 includes the `errors.As` and `errors.Is` APIs.

The base functionality provided by these functions is to cast errors in
an error chain to a specific type or check for equality.

The only definition of error chain currently supported is via errors
which return the underlying cause with a `Unwrap() error` method, but
the design does not make any assumptions otherwise.

Specifically, both, `errors.As` and `errors.Is` support customizing
their behavior by implementing,

    interface { As(interface{}) bool }
    interface { Is(error) bool }

This change does exactly that, making it possible to extract or match
against individual errors in a multierr error. This will work for both,
top-level errors in a multierr error, as well as for errors wrapped by
any of those errors.
4 files changed
tree: b67cfb089b177b1fbb7ab1d5e650b09e9668b348
  1. scripts/
  2. .codecov.yml
  3. .gitignore
  4. .travis.yml
  5. benchmarks_test.go
  6. CHANGELOG.md
  7. error.go
  8. error_test.go
  9. example_test.go
  10. glide.lock
  11. glide.yaml
  12. go113.go
  13. go113_test.go
  14. LICENSE.txt
  15. Makefile
  16. README.md
README.md

multierr GoDoc Build Status Coverage Status

multierr allows combining one or more Go errors together.

Installation

go get -u go.uber.org/multierr

Status

Stable: No breaking changes will be made before 2.0.


Released under the MIT License.