mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Add helpers to create errdef errors
Instead of having to create a bunch of custom error types that are doing
nothing but wrapping another error in sub-packages, use a common helper
to create errors of the requested type.
e.g. instead of re-implementing this over and over:
```go
type notFoundError struct {
cause error
}
func(e notFoundError) Error() string {
return e.cause.Error()
}
func(e notFoundError) NotFound() {}
func(e notFoundError) Cause() error {
return e.cause
}
```
Packages can instead just do:
```
errdefs.NotFound(err)
```
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/containerd/containerd/linux/runctypes"
|
||||
"github.com/docker/docker/api/errdefs"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -16,7 +17,7 @@ func (daemon *Daemon) getRuntimeScript(container *container.Container) (string,
|
||||
name := container.HostConfig.Runtime
|
||||
rt := daemon.configStore.GetRuntime(name)
|
||||
if rt == nil {
|
||||
return "", validationError{errors.Errorf("no such runtime '%s'", name)}
|
||||
return "", errdefs.InvalidParameter(errors.Errorf("no such runtime '%s'", name))
|
||||
}
|
||||
|
||||
if len(rt.Args) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user