-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.go
More file actions
39 lines (32 loc) · 668 Bytes
/
Copy patherror.go
File metadata and controls
39 lines (32 loc) · 668 Bytes
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
package restype
type ErrorKind int
const (
ErrorBodyFromRequest = iota
ErrorExecuteRequest
ErrorResponseFromBytes
)
func (e ErrorKind) Error() string {
switch e {
case ErrorBodyFromRequest:
return "error obtaining body from request"
case ErrorExecuteRequest:
return "error executing request"
case ErrorResponseFromBytes:
return "error deserializing response"
}
return ""
}
type Error struct {
kind ErrorKind
original error
}
func (e Error) Error() string {
return e.kind.Error() + ": " + e.original.Error()
}
func (e Error) Is(target error) bool {
_, ok := target.(Error)
return ok
}
func (e Error) Unwrap() error {
return e.original
}