-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patherrors.go
45 lines (38 loc) · 928 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
package ewelink
import (
"fmt"
)
const (
wrongRegion = 301
authenticationError = 401
invalidRequest = 400
notAcceptable = 406
internalError = 500
)
// APIErrorCause corresponds to a typical api error cause.
type APIErrorCause string
// APIErrorCauses holds information about all known api error causes.
var APIErrorCauses = struct {
WrongRegion APIErrorCause
AuthenticationError APIErrorCause
InvalidRequest APIErrorCause
InternalError APIErrorCause
UnknownError APIErrorCause
}{
WrongRegion: "Wrong region",
AuthenticationError: "Authentication required",
InvalidRequest: "Invalid request",
InternalError: "Internal server error",
}
type apiError struct {
Code int
Message string
Cause APIErrorCause
}
type wrongRegionError struct {
apiError
Region string
}
func (r apiError) Error() string {
return fmt.Sprintf("%#v", r)
}