summaryrefslogtreecommitdiff
path: root/pkg/errorhandling/errorhandling.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-09-11 11:56:18 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-09-11 12:41:15 +0200
commit204493173e26fcb07362804142e3e722a657216e (patch)
treed65c2d66a736fdd66a7cb2c0f6dec91649cd767f /pkg/errorhandling/errorhandling.go
parent2a637948e72faf714b6497bcd57ab0f58485b096 (diff)
downloadpodman-204493173e26fcb07362804142e3e722a657216e.tar.gz
podman-204493173e26fcb07362804142e3e722a657216e.tar.bz2
podman-204493173e26fcb07362804142e3e722a657216e.zip
remote run: fix error checks
As error types are not preserved on the client side (due to marshaling), we cannot use `errors.Cause(...)` and friends but, unfortunately, have to fall back to looking for substring the error messages. Change the error checks in remote run to do substring matches and fix issue #7340. Fixes: #7340 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/errorhandling/errorhandling.go')
-rw-r--r--pkg/errorhandling/errorhandling.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go
index 3117b0ca4..ca6b60bc5 100644
--- a/pkg/errorhandling/errorhandling.go
+++ b/pkg/errorhandling/errorhandling.go
@@ -57,3 +57,11 @@ func CloseQuiet(f *os.File) {
logrus.Errorf("unable to close file %s: %q", f.Name(), err)
}
}
+
+// Contains checks if err's message contains sub's message. Contains should be
+// used iff either err or sub has lost type information (e.g., due to
+// marshaling). For typed errors, please use `errors.Contains(...)` or `Is()`
+// in recent version of Go.
+func Contains(err error, sub error) bool {
+ return strings.Contains(err.Error(), sub.Error())
+}