-
Notifications
You must be signed in to change notification settings - Fork 0
/
revip_errors.go
107 lines (86 loc) · 2.09 KB
/
revip_errors.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package revip
import (
"fmt"
"reflect"
)
// ErrFileNotFound should be returned if configuration file was not found.
type ErrFileNotFound struct {
Path string
Err error
}
func (e *ErrFileNotFound) Error() string {
return fmt.Sprintf("no such file: %q", e.Path)
}
//
// ErrPathNotFound should be returned if key (path) was not found in configuration.
type ErrPathNotFound struct {
Path string
}
func (e *ErrPathNotFound) Error() string {
return fmt.Sprintf("no key matched for path: %q", e.Path)
}
//
// ErrMarshal should be returned if key marshaling failed.
type ErrMarshal struct {
At string
Err error
}
func (e *ErrMarshal) Error() string {
return fmt.Sprintf("failed to marshal at: %q: %s", e.At, e.Err)
}
//
// ErrUnmarshal should be returned if key unmarshaling failed.
type ErrUnmarshal struct {
At string
Err error
}
func (e *ErrUnmarshal) Error() string {
return fmt.Sprintf("failed to unmarshal at: %q: %s", e.At, e.Err)
}
//
// ErrPostprocess represents an error occured at the postprocess stage (set defaults, validation, etc)
type ErrPostprocess struct {
Path string
Err error
}
func (e *ErrPostprocess) Error() string {
return fmt.Sprintf(
"postprocessing failed at %s: %s",
e.Path,
e.Err.Error(),
)
}
//
// ErrUnexpectedKind represents an unexpected interface{} value kind received by some function.
// For example passing non pointer value to a function which expects pointer (like json.Unmarshal)
type ErrUnexpectedKind struct {
Type reflect.Type
Got reflect.Kind
Expected []reflect.Kind
}
func (e *ErrUnexpectedKind) Error() string {
var expected string
if len(e.Expected) > 1 {
expected = fmt.Sprintf("one of %q", e.Expected)
} else {
expected = fmt.Sprintf("%q", e.Expected[0])
}
return fmt.Sprintf(
"unexpected kind %s for type %s, expected "+expected,
e.Got,
e.Type,
)
}
//
// ErrUnexpectedScheme represents an unexpected URL scheme.
type ErrUnexpectedScheme struct {
Got string
Expected []string
}
func (e *ErrUnexpectedScheme) Error() string {
return fmt.Sprintf(
"unexpected scheme %s, expected one of %s",
e.Got,
e.Expected,
)
}