-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
57 lines (48 loc) · 1002 Bytes
/
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
package ishell
// errLevel is the severity of an error.
type errLevel int
const (
warnLevel errLevel = iota + 1
stopLevel
exitLevel
panicLevel
)
var (
noHandlerErr = WarnErr("No handler registered for input.")
)
// shellError is an interractive shell error
type shellError struct {
err string
level errLevel
}
func (s shellError) Error() string {
return s.err
}
// WarnErr creates a Warn level error
func WarnErr(err string) error {
return shellError{
err: err,
level: warnLevel,
}
}
// StopErr creates a Stop level error. Shell stops if encountered.
func StopErr(err string) error {
return shellError{
err: err,
level: stopLevel,
}
}
// ExitErr creates a Exit level error. Program terminates if encountered.
func ExitErr(err string) error {
return shellError{
err: err,
level: exitLevel,
}
}
// PanicErr creates a Panic level error. Program panics if encountered.
func PanicErr(err string) error {
return shellError{
err: err,
level: panicLevel,
}
}