File size: 770 Bytes
7107f0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package tache

import "errors"

// TacheError is a custom error type
type TacheError struct {
	Msg string
}

func (e *TacheError) Error() string {
	return e.Msg
}

// NewErr creates a new TacheError
func NewErr(msg string) error {
	return &TacheError{Msg: msg}
}

//var (
//	ErrTaskNotFound = NewErr("task not found")
//	ErrTaskRunning  = NewErr("task is running")
//)

type unrecoverableError struct {
	error
}

func (e unrecoverableError) Unwrap() error {
	return e.error
}

// Unrecoverable wraps an error in `unrecoverableError` struct
func Unrecoverable(err error) error {
	return unrecoverableError{err}
}

// IsRecoverable checks if error is an instance of `unrecoverableError`
func IsRecoverable(err error) bool {
	return !errors.Is(err, unrecoverableError{})
}