forked from rai-project/model
/
errorcode_enumer.go
77 lines (64 loc) · 2.18 KB
/
errorcode_enumer.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
67
68
69
70
71
72
73
74
75
76
77
// Code generated by "enumer -type=ErrorCode -json"; DO NOT EDIT.
//
package model
import (
"encoding/json"
"fmt"
)
const _ErrorCodeName = "ErrorCodeSuccessErrorCodeInvalidSpecErrorCodeInvalidQueueErrorCodeInvalidErrorCodeTimeoutLimitErrorCodeStorageLimitErrorCodeGPUCountLimitErrorCodeLimitErrorCodePermissionErrorCodeNoServerErrorCodeUnknown"
var _ErrorCodeIndex = [...]uint8{0, 16, 36, 57, 73, 94, 115, 137, 151, 170, 187, 203}
func (i ErrorCode) String() string {
if i < 0 || i >= ErrorCode(len(_ErrorCodeIndex)-1) {
return fmt.Sprintf("ErrorCode(%d)", i)
}
return _ErrorCodeName[_ErrorCodeIndex[i]:_ErrorCodeIndex[i+1]]
}
var _ErrorCodeValues = []ErrorCode{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
var _ErrorCodeNameToValueMap = map[string]ErrorCode{
_ErrorCodeName[0:16]: 0,
_ErrorCodeName[16:36]: 1,
_ErrorCodeName[36:57]: 2,
_ErrorCodeName[57:73]: 3,
_ErrorCodeName[73:94]: 4,
_ErrorCodeName[94:115]: 5,
_ErrorCodeName[115:137]: 6,
_ErrorCodeName[137:151]: 7,
_ErrorCodeName[151:170]: 8,
_ErrorCodeName[170:187]: 9,
_ErrorCodeName[187:203]: 10,
}
// ErrorCodeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ErrorCodeString(s string) (ErrorCode, error) {
if val, ok := _ErrorCodeNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ErrorCode values", s)
}
// ErrorCodeValues returns all values of the enum
func ErrorCodeValues() []ErrorCode {
return _ErrorCodeValues
}
// IsAErrorCode returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ErrorCode) IsAErrorCode() bool {
for _, v := range _ErrorCodeValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for ErrorCode
func (i ErrorCode) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for ErrorCode
func (i *ErrorCode) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("ErrorCode should be a string, got %s", data)
}
var err error
*i, err = ErrorCodeString(s)
return err
}