From 7902849dc021610b0ec16d1130b9515efd1f64b1 Mon Sep 17 00:00:00 2001 From: Keuin Date: Wed, 14 Sep 2022 03:02:51 +0800 Subject: Refactor: proper error handling. --- recording/errors.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 recording/errors.go (limited to 'recording/errors.go') diff --git a/recording/errors.go b/recording/errors.go new file mode 100644 index 0000000..48a492e --- /dev/null +++ b/recording/errors.go @@ -0,0 +1,33 @@ +package recording + +import "fmt" + +/* +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} +} -- cgit v1.2.3