/
error.go
48 lines (43 loc) · 1.18 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
package core
// ErrCode error code
type ErrCode int
const (
// UnknownErr unknown error code
UnknownErr ErrCode = iota
// ExtractImageSizeTooSmallErr extract image size is too small
ExtractImageSizeTooSmallErr
// NoFaceErr no face detected error
NoFaceErr
// InferenceFailedErr extract face failed
InferenceFailedErr
// ImageToTensorSizeErr convert image to tensor size error
ImageToTensorSizeErr
// NegativeDistanceMatchErr match distance is negative
NegativeDistanceMatchErr
// TooFarMatchErr match distance is too far
TooFarMatchErr
// CollisionMatchErr match distance is larger than collision radius, may need more trainning data
CollisionMatchErr
// NothingMatchErr represents nothing matched
NothingMatchErr
// UnknownClassifierErr represents met an unknown classifier in saved db
UnknownClassifierErr
)
// Error custom error object
type Error struct {
// Code error code
Code ErrCode `json:"code,omitempty"`
// Msg error message
Msg string `json:"msg,omitempty"`
}
// NewError create an error
func NewError(code ErrCode, msg string) Error {
return Error{
Code: code,
Msg: msg,
}
}
// Error implement error interface
func (e Error) Error() string {
return e.Msg
}