diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/errors.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/common/errors.go b/common/errors.go index ba686f1..fa2d492 100644 --- a/common/errors.go +++ b/common/errors.go @@ -2,6 +2,7 @@ package common import ( "errors" + "fmt" "reflect" ) @@ -27,3 +28,33 @@ func IsErrorOfType(err, target error) bool { } } } + +/* +Task errors. +*/ + +type RecoverableTaskError struct { + err error + message string +} + +func (e *RecoverableTaskError) Error() string { + return fmt.Sprintf("%v: %v", e.message, e.err) +} + +func NewRecoverableTaskError(message string, err error) error { + return &RecoverableTaskError{message: message, err: err} +} + +type UnrecoverableTaskError struct { + err error + message string +} + +func (e *UnrecoverableTaskError) Error() string { + return fmt.Sprintf("%v: %v", e.message, e.err) +} + +func NewUnrecoverableTaskError(message string, err error) error { + return &UnrecoverableTaskError{message: message, err: err} +} |