summaryrefslogtreecommitdiff
path: root/pkg/errorhandling/errorhandling.go
diff options
context:
space:
mode:
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())
+}