From 1874ac0679837f1fb98c4874892906e859d8305a Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Thu, 19 Sep 2024 10:55:04 +0530 Subject: [PATCH] Error util to check one of. (#815) --- utils/error.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils/error.go diff --git a/utils/error.go b/utils/error.go new file mode 100644 index 00000000..1a45d159 --- /dev/null +++ b/utils/error.go @@ -0,0 +1,12 @@ +package utils + +import "errors" + +func ErrorIsOneOf(err error, targets ...error) bool { + for _, t := range targets { + if errors.Is(err, t) { + return true + } + } + return false +}