diff --git a/container/view.go b/container/view.go index 9b63c74eef..837345d3e7 100644 --- a/container/view.go +++ b/container/view.go @@ -30,21 +30,6 @@ var ( ErrNameNotReserved = errors.New("name is not reserved") ) -var ( - // ErrEmptyPrefix is an error returned if the prefix was empty. - ErrEmptyPrefix = errors.New("Prefix can't be empty") -) - -// ErrAmbiguousPrefix is returned if the prefix was ambiguous -// (multiple ids for the prefix). -type ErrAmbiguousPrefix struct { - prefix string -} - -func (e ErrAmbiguousPrefix) Error() string { - return fmt.Sprintf("Multiple IDs found with provided prefix: %s", e.prefix) -} - // Snapshot is a read only view for Containers. It holds all information necessary to serve container queries in a // versioned ACID in-memory store. type Snapshot struct { @@ -124,12 +109,12 @@ func NewViewDB() (*ViewDB, error) { // error if an empty prefix was given or if multiple containers match the prefix. func (db *ViewDB) GetByPrefix(s string) (string, error) { if s == "" { - return "", ErrEmptyPrefix + return "", errdefs.InvalidParameter(errors.New("prefix can't be empty")) } txn := db.store.Txn(false) iter, err := txn.Get(memdbContainersTable, memdbIDIndexPrefix, s) if err != nil { - return "", err + return "", errdefs.System(err) } var ( @@ -142,7 +127,7 @@ func (db *ViewDB) GetByPrefix(s string) (string, error) { break } if id != "" { - return "", ErrAmbiguousPrefix{prefix: s} + return "", errdefs.InvalidParameter(errors.New("multiple IDs found with provided prefix: " + s)) } id = item.(*Container).ID } diff --git a/daemon/container.go b/daemon/container.go index 75d6c48a26..3cfa0107c2 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -50,10 +50,7 @@ func (daemon *Daemon) GetContainer(prefixOrName string) (*container.Container, e containerID, err := daemon.containersReplica.GetByPrefix(prefixOrName) if err != nil { - if errdefs.IsNotFound(err) { - return nil, err - } - return nil, errdefs.System(err) + return nil, err } return daemon.containers.Get(containerID), nil }