1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
Commit graph

4 commits

Author SHA1 Message Date
Sebastiaan van Stijn
d48392a35b
Fix definition of ErrSystem type
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-03-05 23:42:23 +01:00
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
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Brian Goff
d453fe35b9 Move api/errdefs to errdefs
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-01-11 21:21:43 -05:00