-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
54 lines (41 loc) · 813 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
47
48
49
50
51
52
53
54
package certsurfer
import (
"errors"
"fmt"
)
func IsDialError(err error) bool {
return errors.As(err, &dialError{})
}
type dialError struct {
err error
}
func (e dialError) Error() string {
return fmt.Sprintf("error dailing: %v", e.err)
}
func (e dialError) Unwrap() error {
return e.err
}
func IsReadError(err error) bool {
return errors.As(err, &readError{})
}
type readError struct {
err error
}
func (e readError) Error() string {
return fmt.Sprintf("error reading: %v", e.err)
}
func (e readError) Unwrap() error {
return e.err
}
func IsJsonError(err error) bool {
return errors.As(err, &jsonError{})
}
type jsonError struct {
err error
}
func (e jsonError) Error() string {
return fmt.Sprintf("error unmarshalling: %v", e.err)
}
func (e jsonError) Unwrap() error {
return e.err
}