Commit Graph

8 Commits

Author SHA1 Message Date
Sebastiaan van Stijn 264775b52b
Make errdefs helpers idempotent
Don't convert errors if they already have the right type

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-01-03 11:16:01 +01:00
Sebastiaan van Stijn 43a8ec654b
Add missing nil-check on errdefs.Unavailable()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-12-30 15:18:57 +01:00
Kazuhiro Sera 1e49fdcafc Fix the several typos detected by github.com/client9/misspell
Signed-off-by: Kazuhiro Sera <seratch@gmail.com>
2018-08-09 00:45:00 +09:00
ohbarye 0f95b23d98 Fix typos: remove duplicated "the"
Signed-off-by: Masato Ohba <over.rye@gmail.com>
2018-05-17 21:49:51 +09:00
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