summaryrefslogtreecommitdiff
path: root/cmd/podman/root.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-09 15:24:58 -0400
committerGitHub <noreply@github.com>2020-10-09 15:24:58 -0400
commitcec240375d6dceb09c705d6d55e67aeff037327f (patch)
treeee290e59ed69988c7ad09d8a60a78ef3f284f0c5 /cmd/podman/root.go
parentffabd57d6de01c5c65b2e2291b6a6564d28263a0 (diff)
parentc47a1b1e550a361a009156e14fcc933dfbbdee64 (diff)
downloadpodman-cec240375d6dceb09c705d6d55e67aeff037327f.tar.gz
podman-cec240375d6dceb09c705d6d55e67aeff037327f.tar.bz2
podman-cec240375d6dceb09c705d6d55e67aeff037327f.zip
Merge pull request #7968 from xordspar0/oci-runtime-error
Print the correct underlying cause for OCI errors
Diffstat (limited to 'cmd/podman/root.go')
-rw-r--r--cmd/podman/root.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 1e73f7540..6293fa17d 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/validate"
+ "github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/parallel"
"github.com/containers/podman/v2/pkg/rootless"
@@ -84,7 +85,7 @@ func init() {
func Execute() {
if err := rootCmd.ExecuteContext(registry.GetContextWithOptions()); err != nil {
- fmt.Fprintln(os.Stderr, "Error:", err.Error())
+ fmt.Fprintln(os.Stderr, formatError(err))
} else if registry.GetExitCode() == registry.ExecErrorCodeGeneric {
// The exitCode modified from registry.ExecErrorCodeGeneric,
// indicates an application
@@ -331,3 +332,19 @@ func resolveDestination() (string, string, string) {
}
return cfg.Engine.ActiveService, uri, ident
}
+
+func formatError(err error) string {
+ var message string
+ if errors.Cause(err) == define.ErrOCIRuntime {
+ // OCIRuntimeErrors include the reason for the failure in the
+ // second to last message in the error chain.
+ message = fmt.Sprintf(
+ "Error: %s: %s",
+ define.ErrOCIRuntime.Error(),
+ strings.TrimSuffix(err.Error(), ": "+define.ErrOCIRuntime.Error()),
+ )
+ } else {
+ message = "Error: " + err.Error()
+ }
+ return message
+}