59854e407d
The types defined in the errdefs package do not satisfy the `error` interface, because they do not implement `Error()`. Instead of returning the matched interface, return the original error. When matching _multiple_ interfaces/types, Golang doesn't complain: func getImplementer(err error) error { switch e := err.(type) { case ErrNotFound, ErrInvalidParameter: return e default: return err } } But matching a single interface/type: func getImplementer(err error) error { switch e := err.(type) { case ErrNotFound: return e default: return err } } Produces an error: cannot use e (type ErrNotFound) as type error in return argument: ErrNotFound does not implement error (missing Error method) Return the original `err` instead of the matched interface/type instead. Also added some additional tests Signed-off-by: Sebastiaan van Stijn <github@gone.nl> |
||
---|---|---|
.. | ||
defs.go | ||
doc.go | ||
helpers.go | ||
helpers_test.go | ||
is.go |