summaryrefslogtreecommitdiff
path: root/internal/gtserror/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/gtserror/error.go')
-rw-r--r--internal/gtserror/error.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/gtserror/error.go b/internal/gtserror/error.go
index e68ed7d3b..6eaa3db63 100644
--- a/internal/gtserror/error.go
+++ b/internal/gtserror/error.go
@@ -33,11 +33,35 @@ const (
statusCodeKey
notFoundKey
errorTypeKey
+ unrtrvableKey
+ wrongTypeKey
// Types returnable from Type(...).
TypeSMTP ErrorType = "smtp" // smtp (mail)
)
+// Unretrievable ...
+func Unretrievable(err error) bool {
+ _, ok := errors.Value(err, unrtrvableKey).(struct{})
+ return ok
+}
+
+// SetUnretrievable ...
+func SetUnretrievable(err error) error {
+ return errors.WithValue(err, unrtrvableKey, struct{}{})
+}
+
+// WrongType ...
+func WrongType(err error) bool {
+ _, ok := errors.Value(err, wrongTypeKey).(struct{})
+ return ok
+}
+
+// SetWrongType ...
+func SetWrongType(err error) error {
+ return errors.WithValue(err, unrtrvableKey, struct{}{})
+}
+
// StatusCode checks error for a stored status code value. For example
// an error from an outgoing HTTP request may be stored, or an API handler
// expected response status code may be stored.