-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
87 lines (70 loc) · 1.58 KB
/
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
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
package value
import (
"reflect"
)
type (
// ErrNumOverflow ...
ErrNumOverflow struct {
Method string
Kind reflect.Kind
}
// ErrUnsupportedKind ...
ErrUnsupportedKind struct {
Method string
Kind interface{}
}
// ErrCannotBeNil ...
ErrCannotBeNil struct {
Method string
}
// ErrNotExist ...
ErrNotExist struct {
Method string
Thing string
}
// ErrCannotSet ...
ErrCannotSet struct {
Method string
}
// ErrTypeUnequal ...
ErrTypeUnequal struct {
Method string
Kind1 reflect.Kind
Kind2 reflect.Kind
}
// ErrOutOfRange ...
ErrOutOfRange struct {
Method string
}
)
func (e *ErrUnsupportedKind) Error() string {
rkind, ok := e.Kind.(reflect.Kind)
if ok && rkind == 0 {
return "table: call of " + e.Method + " on zero value"
}
var kind string
if ok {
kind = rkind.String()
} else {
kind, _ = e.Kind.(string)
}
return "table: call of " + e.Method + " on " + kind + " value"
}
func (e *ErrNumOverflow) Error() string {
return "table: call of " + e.Method + " overflows " + e.Kind.String()
}
func (e *ErrCannotBeNil) Error() string {
return "table: call of " + e.Method + " on nil value"
}
func (e *ErrNotExist) Error() string {
return "table: call of " + e.Method + " not exist of " + e.Thing
}
func (e *ErrCannotSet) Error() string {
return "table: call of " + e.Method + " on unaddressable value"
}
func (e *ErrTypeUnequal) Error() string {
return "table: call of " + e.Method + " between " + e.Kind1.String() + " and " + e.Kind2.String()
}
func (e *ErrOutOfRange) Error() string {
return "table: call of " + e.Method + " out of range"
}