-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_code.go
61 lines (52 loc) · 1.09 KB
/
error_code.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
package main
import "net/http"
// Status wraps HTTPStatus and Error in pb.
type Status struct {
HTTPStatus int
Code string
Message string
}
// IsOK ...
func (err *Status) IsOK() bool {
return err.HTTPStatus == http.StatusOK
}
func newStatusOK() Status {
return Status{
HTTPStatus: http.StatusOK,
}
}
func newAccessKeyIDNotExistError() Status {
return Status{
HTTPStatus: 403,
Code: "OTSAuthFailed",
Message: "The AccessKeyID does not exist.",
}
}
func newAccessKeyIDDisabledError() Status {
return Status{
HTTPStatus: 403,
Code: "OTSAuthFailed",
Message: "The AccessKeyID is disabled.",
}
}
func newUserNotExistError() Status {
return Status{
HTTPStatus: 403,
Code: "OTSAuthFailed",
Message: "The user does not exist.",
}
}
func newInstanceNotFoundError() Status {
return Status{
HTTPStatus: 403,
Code: "OTSAuthFailed",
Message: "The instance is not found.",
}
}
func newInternalServerError() Status {
return Status{
HTTPStatus: 500,
Code: "OTSInternalServerError",
Message: "Internal server error.",
}
}