forked from Kagami/go-face
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
38 lines (30 loc) · 813 Bytes
/
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
package face
// #include <stdint.h>
// #include "facerec.h"
import "C"
// An ImageLoadError is returned when provided image file is corrupted.
type ImageLoadError string
func (e ImageLoadError) Error() string {
return string(e)
}
// An SerializationError is returned when provided model is corrupted.
type SerializationError string
func (e SerializationError) Error() string {
return string(e)
}
// An UnknownError represents some nonclassified error.
type UnknownError string
func (e UnknownError) Error() string {
return string(e)
}
// makeError constructs Go error for passed error info.
func makeError(s string, code int) error {
switch code {
case C.IMAGE_LOAD_ERROR:
return ImageLoadError(s)
case C.SERIALIZATION_ERROR:
return SerializationError(s)
default:
return UnknownError(s)
}
}