-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
106 lines (86 loc) · 2.1 KB
/
errors.go
File metadata and controls
106 lines (86 loc) · 2.1 KB
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
package clistruct
import (
"fmt"
"reflect"
)
// ErrInvalid is an error indicating that invalid values was passed.
type ErrInvalid struct {
v interface{}
}
func (e *ErrInvalid) Error() string {
return fmt.Sprintf(
"Reflect reports this value is invalid '%#v'",
e.v,
)
}
// NewErrInvalid creates new ErrInvalid.
func NewErrInvalid(v interface{}) error {
return &ErrInvalid{v}
}
//
// ErrInvalidKind is an error indicating that reflect.Kind of
// value is not expected in the context it was used.
type ErrInvalidKind struct {
expected reflect.Kind
got reflect.Kind
}
func (e *ErrInvalidKind) Error() string {
return fmt.Sprintf(
"Expected '%s' kind, got '%s'",
e.expected,
e.got,
)
}
// NewErrInvalidKind creates new ErrInvalidKind.
func NewErrInvalidKind(expected, got reflect.Kind) error {
return &ErrInvalidKind{expected, got}
}
//
// ErrPtrRequired is an error indicating that a pointer entity required.
type ErrPtrRequired struct {
v interface{}
}
func (e *ErrPtrRequired) Error() string {
return fmt.Sprintf(
"A pointer to the value '%#v' is required, not the value itself",
e.v,
)
}
// NewErrPtrRequired creates new ErrPtrRequired.
func NewErrPtrRequired(v interface{}) error {
return &ErrPtrRequired{v}
}
//
// ErrTypeMistmatch is an error indicating that a wanted type
// is not equal to actual.
type ErrTypeMistmatch struct {
want string
got string
}
func (e *ErrTypeMistmatch) Error() string {
return fmt.Sprintf(
"Type mistmatch, want '%s', got '%s'",
e.want,
e.got,
)
}
// NewErrTypeMistmatch creates new ErrTypeMistmatch.
func NewErrTypeMistmatch(want string, got string) error {
return &ErrTypeMistmatch{want, got}
}
//
// ErrFlagTypeCanNotHaveValue is an error indicating that
// flag type with specified name takes no value.
type ErrFlagTypeCanNotHaveValue struct {
t string
}
func (e *ErrFlagTypeCanNotHaveValue) Error() string {
return fmt.Sprintf(
"Flag of type '%s' can not have value",
e.t,
)
}
// NewErrFlagTypeCanNotHaveValue creates new ErrFlagTypeCanNotHaveValue.
func NewErrFlagTypeCanNotHaveValue(t string) error {
return &ErrFlagTypeCanNotHaveValue{t}
}