Skip to content

Commit fe2de4f

Browse files
boaz0rh-atomic-bot
authored andcommitted
Handle commit error gracefully
This change gives a better error message when the commit fails because of bad authentication. Signed-off-by: Boaz Shuster <[email protected]> Closes: #385 Approved by: rhatdan
1 parent adfb256 commit fe2de4f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/buildah/commit.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/containers/image/storage"
99
"github.com/containers/image/transports/alltransports"
1010
"github.com/containers/storage/pkg/archive"
11+
"github.com/docker/distribution/registry/api/errcode"
1112
"github.com/pkg/errors"
1213
"github.com/projectatomic/buildah"
1314
"github.com/urfave/cli"
@@ -143,7 +144,14 @@ func commitCmd(c *cli.Context) error {
143144
}
144145
err = builder.Commit(dest, options)
145146
if err != nil {
146-
return errors.Wrapf(err, "error committing container %q to %q", builder.Container, image)
147+
switch nErr := errors.Cause(err).(type) {
148+
case errcode.Errors:
149+
return cli.NewMultiError([]error(nErr)...)
150+
case errcode.Error:
151+
return nErr
152+
default:
153+
return errors.Wrapf(err, "error committing container %q to %q", builder.Container, image)
154+
}
147155
}
148156

149157
if c.Bool("rm") {

0 commit comments

Comments
 (0)