aboutsummaryrefslogtreecommitdiffhomepage
path: root/common/herrors/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/herrors/errors.go')
-rw-r--r--common/herrors/errors.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/herrors/errors.go b/common/herrors/errors.go
index 40833e55c..c7ee90dd0 100644
--- a/common/herrors/errors.go
+++ b/common/herrors/errors.go
@@ -133,6 +133,21 @@ func IsNotExist(err error) bool {
return false
}
+// IsExist returns true if the error is a file exists error.
+// Unlike os.IsExist, this also considers wrapped errors.
+func IsExist(err error) bool {
+ if os.IsExist(err) {
+ return true
+ }
+
+ // os.IsExist does not consider wrapped errors.
+ if os.IsExist(errors.Unwrap(err)) {
+ return true
+ }
+
+ return false
+}
+
var nilPointerErrRe = regexp.MustCompile(`at <(.*)>: error calling (.*?): runtime error: invalid memory address or nil pointer dereference`)
const deferredPrefix = "__hdeferred/"