-
Notifications
You must be signed in to change notification settings - Fork 2
/
ErrorMessages.go
66 lines (52 loc) · 1.65 KB
/
ErrorMessages.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
package unhtml
import (
"fmt"
"reflect"
)
const (
UnmarshaledKindMustBePtr = "unmarshaled kind must be Ptr"
UnmarshalerItemKind = "unmarshaled elem cannot be Ptr/Uintptr/Interface/Chan/Func/"
DtoZero = "dto cannot be zero"
SelectionNil = "selection cannot be nil"
ConverterNotExist = "converter not exist"
ConverterTypeWrong = "type of converter is wrong"
)
type (
UnmarshaledKindMustBePtrError struct {
dtoType reflect.Type
}
UnmarshalerItemKindError struct {
dtoType reflect.Type
}
ConverterNotExistError struct {
name string
}
ConverterTypeWrongError struct {
name string
methodType reflect.Type
}
)
func NewUnmarshaledKindMustBePtrError(dtoType reflect.Type) *UnmarshaledKindMustBePtrError {
return &UnmarshaledKindMustBePtrError{dtoType}
}
func NewUnmarshalerItemKindError(dtoType reflect.Type) *UnmarshalerItemKindError {
return &UnmarshalerItemKindError{dtoType}
}
func NewConverterNotExistError(name string) *ConverterNotExistError {
return &ConverterNotExistError{name}
}
func NewConverterTypeWrongError(name string, methodType reflect.Type) *ConverterTypeWrongError {
return &ConverterTypeWrongError{name, methodType}
}
func (err UnmarshaledKindMustBePtrError) Error() string {
return UnmarshaledKindMustBePtr + ": " + err.dtoType.String()
}
func (err UnmarshalerItemKindError) Error() string {
return UnmarshalerItemKind + ": " + err.dtoType.String()
}
func (err ConverterNotExistError) Error() string {
return ConverterNotExist + ": " + err.name
}
func (err ConverterTypeWrongError) Error() string {
return fmt.Sprintf(ConverterTypeWrong+"(%s): %s", err.name, err.methodType)
}