summaryrefslogtreecommitdiff
path: root/common/errors.go
blob: bdf49fb30e2ee2d97bc92c3632cef6f7261bf1d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package common

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 (e *RecoverableTaskError) Unwrap() error {
	return 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 (e *UnrecoverableTaskError) Unwrap() error {
	return e.err
}

func NewUnrecoverableTaskError(message string, err error) error {
	return &UnrecoverableTaskError{message: message, err: err}
}