Merge pull request #1766 from dnephin/fix-error-message

Normalize 'already exists' errors
This commit is contained in:
Derek McGowan 2017-11-15 14:53:20 -08:00 committed by GitHub
commit 96d2c1e0c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -105,7 +105,7 @@ func (s *containerStore) Create(ctx context.Context, container containers.Contai
cbkt, err := bkt.CreateBucket([]byte(container.ID))
if err != nil {
if err == bolt.ErrBucketExists {
err = errors.Wrapf(errdefs.ErrAlreadyExists, "content %q", container.ID)
err = errors.Wrapf(errdefs.ErrAlreadyExists, "container %q", container.ID)
}
return containers.Container{}, err
}

View File

@ -55,7 +55,7 @@ func (lm *LeaseManager) Create(ctx context.Context, lid string, labels map[strin
if err == bolt.ErrBucketExists {
err = errdefs.ErrAlreadyExists
}
return Lease{}, err
return Lease{}, errors.Wrapf(err, "lease %q", lid)
}
t := time.Now().UTC()

View File

@ -284,7 +284,7 @@ func (s *snapshotter) createSnapshot(ctx context.Context, key, parent string, re
bbkt, err := bkt.CreateBucket([]byte(key))
if err != nil {
if err == bolt.ErrBucketExists {
err = errors.Wrapf(errdefs.ErrAlreadyExists, "snapshot %v already exists", key)
err = errors.Wrapf(errdefs.ErrAlreadyExists, "snapshot %q", key)
}
return err
}
@ -373,7 +373,7 @@ func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
bbkt, err := bkt.CreateBucket([]byte(name))
if err != nil {
if err == bolt.ErrBucketExists {
err = errors.Wrapf(errdefs.ErrAlreadyExists, "snapshot %v already exists", name)
err = errors.Wrapf(errdefs.ErrAlreadyExists, "snapshot %q", name)
}
return err
}

View File

@ -36,7 +36,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
status, err := p.tracker.GetStatus(ref)
if err == nil {
if status.Offset == status.Total {
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "ref %v already exists", ref)
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "ref %v", ref)
}
// TODO: Handle incomplete status
} else if !errdefs.IsNotFound(err) {