forked from rwxrob/bonzai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
141 lines (102 loc) · 2.96 KB
/
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package Z
import "fmt"
type NotEnoughArgs struct {
Count int
Min int
}
func (e NotEnoughArgs) Error() string {
return fmt.Sprintf(
"error: %v is not enough args, %v required", e.Count, e.Min)
}
// -------------------------------- -- --------------------------------
type TooManyArgs struct {
Count int
Max int
}
func (e TooManyArgs) Error() string {
return fmt.Sprintf(
"error: %v is too many args, %v maximum", e.Count, e.Max)
}
// -------------------------------- -- --------------------------------
type WrongNumArgs struct {
Count int
Num int
}
func (e WrongNumArgs) Error() string {
return fmt.Sprintf(
"error: %v is wrong number of args, %v required", e.Count, e.Num)
}
// -------------------------------- -- --------------------------------
type MissingConf struct {
Path string
}
func (e MissingConf) Error() string {
return fmt.Sprintf("missing conf value for %v", e.Path)
}
// -------------------------------- -- --------------------------------
type MissingVar struct {
Path string
}
func (e MissingVar) Error() string {
return fmt.Sprintf("missing var for %v", e.Path)
}
// -------------------------------- -- --------------------------------
type UsesConf struct {
Cmd *Cmd
}
func (e UsesConf) Error() string {
return fmt.Sprintf("%v requires Z.Conf", e.Cmd.Name)
}
// -------------------------------- -- --------------------------------
type UsesVars struct {
Cmd *Cmd
}
func (e UsesVars) Error() string {
return fmt.Sprintf("%v requires Z.Vars", e.Cmd.Name)
}
// -------------------------------- -- --------------------------------
type NoCallNoCommands struct {
Cmd *Cmd
}
func (e NoCallNoCommands) Error() string {
return fmt.Sprintf("%v requires either Call or Commands", e.Cmd.Name)
}
// -------------------------------- -- --------------------------------
type DefCmdReqCall struct {
Cmd *Cmd
}
func (e DefCmdReqCall) Error() string {
return fmt.Sprintf("default (first) %q Commands requires Call", e.Cmd.Name)
}
// -------------------------------- -- --------------------------------
type IncorrectUsage struct {
Cmd *Cmd
}
func (e IncorrectUsage) Error() string {
return fmt.Sprintf("usage: %v %v", e.Cmd.Name, e.Cmd.GetUsage())
}
// -------------------------------- -- --------------------------------
type MultiCallCmdNotFound struct {
CmdName string
}
func (e MultiCallCmdNotFound) Error() string {
return fmt.Sprintf("multicall command not found: %v", e.CmdName)
}
// -------------------------------- -- --------------------------------
type MultiCallCmdNotCmd struct {
CmdName string
It any
}
func (e MultiCallCmdNotCmd) Error() string {
return fmt.Sprintf(
"multicall match for %v, but first in slice not *Z.Cmd: %T", e.CmdName, e.It)
}
// -------------------------------- -- --------------------------------
type MultiCallCmdArgNotString struct {
CmdName string
It any
}
func (e MultiCallCmdArgNotString) Error() string {
return fmt.Sprintf(
"multicall match for %v, but arg not string: %T", e.CmdName, e.It)
}