moby/errdefs
Sebastiaan van Stijn 59854e407d
Change return for errdefs.getImplementer()
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>
2018-03-05 23:41:58 +01:00
..
defs.go Add canonical import comment 2018-02-05 16:51:57 -05:00
doc.go Add canonical import comment 2018-02-05 16:51:57 -05:00
helpers.go Add canonical import comment 2018-02-05 16:51:57 -05:00
helpers_test.go Change return for errdefs.getImplementer() 2018-03-05 23:41:58 +01:00
is.go Change return for errdefs.getImplementer() 2018-03-05 23:41:58 +01:00