-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
46 lines (36 loc) · 878 Bytes
/
error.go
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
44
45
46
package copper
import (
"fmt"
)
var _ error = SentinelError{}
type SentinelError struct {
msg string
}
func (s SentinelError) Error() string {
return s.msg
}
var (
ErrNotChecked = SentinelError{"not checked"}
ErrNotPartOfSpec = SentinelError{"not part of spec"}
ErrResponseInvalid = SentinelError{"response invalid"}
ErrRequestInvalid = SentinelError{"request invalid"}
)
func joinError(sentinel SentinelError, err error) *VerificationError {
return &VerificationError{
err: err,
sentinel: sentinel,
}
}
type VerificationError struct {
err error
sentinel SentinelError
}
func (v *VerificationError) Sentinel() error {
return v.sentinel
}
func (v *VerificationError) Error() string {
return fmt.Sprintf("%v: %v", v.sentinel.Error(), v.err.Error())
}
func (v *VerificationError) Unwrap() []error {
return []error{v.err, v.sentinel}
}