-
Notifications
You must be signed in to change notification settings - Fork 0
/
RPC_error.go
133 lines (127 loc) · 7.51 KB
/
RPC_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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package acm
import (
"net/http"
)
// RPC errors.
// Error codes must not exceed 999.
// Codes.
const (
RpcErrorCode_AuthChallengeResponseIsNotSet = 1
RpcErrorCode_BPP_GenerateRandomSalt = 2
RpcErrorCode_BPP_PackSymbols = 3
RpcErrorCode_CaptchaAnswerIsNotSet = 4
RpcErrorCode_CaptchaAnswerIsWrong = 5
RpcErrorCode_EmailAddressIsNotValid = 6
RpcErrorCode_EmailAddressIsUsed = 7
RpcErrorCode_EmailChangeIsNotFound = 8
RpcErrorCode_JWTCreation = 9
RpcErrorCode_NameIsNotSet = 10
RpcErrorCode_NameIsTooLong = 11
RpcErrorCode_NameIsUsed = 12
RpcErrorCode_NewPasswordIsNotSet = 13
RpcErrorCode_NewEmailIsNotSet = 14
RpcErrorCode_PasswordChangeIsNotFound = 15
RpcErrorCode_PasswordIsNotValid = 16
RpcErrorCode_PasswordIsNotSet = 17
RpcErrorCode_PasswordIsTooLong = 18
RpcErrorCode_PasswordIsWrong = 19
RpcErrorCode_RequestIdGenerator = 20
RpcErrorCode_RequestIdIsNotSet = 21
RpcErrorCode_SmtpModule = 22
RpcErrorCode_StepIsUnknown = 23
RpcErrorCode_UserAlreadyStartedToChangePassword = 24
RpcErrorCode_UserAlreadyStartedToChangeEmail = 25
RpcErrorCode_UserCanNotLogIn = 26
RpcErrorCode_UserHasAlreadyStartedToLogIn = 27
RpcErrorCode_UserHasNotStartedToLogIn = 28
RpcErrorCode_UserIdIsNotSet = 29
RpcErrorCode_UserIsAlreadyLoggedIn = 30
RpcErrorCode_UserIsNotFound = 31
RpcErrorCode_UserPreSessionIsNotFound = 32
RpcErrorCode_VerificationCodeGenerator = 33
RpcErrorCode_VerificationCodeIsNotSet = 34
RpcErrorCode_VerificationCodeIsWrong = 35
)
// Messages.
const (
RpcErrorMsg_AuthChallengeResponseIsNotSet = "authorisation challenge response is not set"
RpcErrorMsg_BPP_GenerateRandomSalt = "BPP: GenerateRandomSalt error"
RpcErrorMsgF_BPP_PackSymbols = "BPP: PackSymbols error: %s" // Template.
RpcErrorMsg_CaptchaAnswerIsNotSet = "captcha answer is not set"
RpcErrorMsg_CaptchaAnswerIsWrong = "captcha answer is wrong"
RpcErrorMsg_EmailAddressIsNotValid = "e-mail address is not valid"
RpcErrorMsg_EmailAddressIsUsed = "e-mail address is used"
RpcErrorMsg_EmailChangeIsNotFound = "request for e-mail address change is not found"
RpcErrorMsgF_JWTCreation = "JWT creation error: %s" // Template.
RpcErrorMsg_NameIsNotSet = "name is not set"
RpcErrorMsg_NameIsTooLong = "name is too long"
RpcErrorMsg_NameIsUsed = "name is already used"
RpcErrorMsg_NewPasswordIsNotSet = "new password is not set"
RpcErrorMsg_NewEmailIsNotSet = "new e-mail address is not set"
RpcErrorMsg_PasswordChangeIsNotFound = "request for password change is not found"
RpcErrorMsg_PasswordIsNotValid = "password is not valid"
RpcErrorMsg_PasswordIsNotSet = "password is not set"
RpcErrorMsg_PasswordIsTooLong = "password is too long"
RpcErrorMsg_PasswordIsWrong = "password is wrong"
RpcErrorMsg_RequestIdGenerator = "error generating request ID"
RpcErrorMsg_RequestIdIsNotSet = "request ID is not set"
RpcErrorMsg_SmtpModule = "SMTP module error"
RpcErrorMsg_StepIsUnknown = "unknown step"
RpcErrorMsg_UserAlreadyStartedToChangePassword = "user has already started to change password"
RpcErrorMsg_UserAlreadyStartedToChangeEmail = "user has already started to change e-mail address"
RpcErrorMsg_UserCanNotLogIn = "user can not log in"
RpcErrorMsg_UserHasAlreadyStartedToLogIn = "user has already started to log in"
RpcErrorMsg_UserHasNotStartedToLogIn = "user has not started to log in"
RpcErrorMsg_UserIdIsNotSet = "user ID is not set"
RpcErrorMsg_UserIsAlreadyLoggedIn = "user is already logged in"
RpcErrorMsg_UserIsNotFound = "user is not found"
RpcErrorMsg_UserPreSessionIsNotFound = "user's preliminary session is not found"
RpcErrorMsg_VerificationCodeGenerator = "verification code generator error"
RpcErrorMsg_VerificationCodeIsNotSet = "verification code is not set"
RpcErrorMsg_VerificationCodeIsWrong = "verification code is wrong"
)
// Unique HTTP status codes used in the map:
// - 400 (Bad request);
// - 403 (Forbidden);
// - 404 (Not found);
// - 409 (Conflict);
// - 500 (Internal server error).
func GetMapOfHttpStatusCodesByRpcErrorCodes() map[int]int {
return map[int]int{
RpcErrorCode_AuthChallengeResponseIsNotSet: http.StatusBadRequest,
RpcErrorCode_BPP_GenerateRandomSalt: http.StatusInternalServerError,
RpcErrorCode_BPP_PackSymbols: http.StatusInternalServerError,
RpcErrorCode_CaptchaAnswerIsNotSet: http.StatusBadRequest,
RpcErrorCode_CaptchaAnswerIsWrong: http.StatusForbidden,
RpcErrorCode_EmailAddressIsNotValid: http.StatusBadRequest,
RpcErrorCode_EmailAddressIsUsed: http.StatusConflict,
RpcErrorCode_EmailChangeIsNotFound: http.StatusNotFound,
RpcErrorCode_JWTCreation: http.StatusInternalServerError,
RpcErrorCode_NameIsNotSet: http.StatusBadRequest,
RpcErrorCode_NameIsTooLong: http.StatusBadRequest,
RpcErrorCode_NameIsUsed: http.StatusConflict,
RpcErrorCode_NewPasswordIsNotSet: http.StatusBadRequest,
RpcErrorCode_NewEmailIsNotSet: http.StatusBadRequest,
RpcErrorCode_PasswordChangeIsNotFound: http.StatusNotFound,
RpcErrorCode_PasswordIsNotValid: http.StatusBadRequest,
RpcErrorCode_PasswordIsNotSet: http.StatusBadRequest,
RpcErrorCode_PasswordIsTooLong: http.StatusBadRequest,
RpcErrorCode_PasswordIsWrong: http.StatusForbidden,
RpcErrorCode_RequestIdGenerator: http.StatusInternalServerError,
RpcErrorCode_RequestIdIsNotSet: http.StatusBadRequest,
RpcErrorCode_SmtpModule: http.StatusInternalServerError,
RpcErrorCode_StepIsUnknown: http.StatusBadRequest,
RpcErrorCode_UserAlreadyStartedToChangePassword: http.StatusForbidden,
RpcErrorCode_UserAlreadyStartedToChangeEmail: http.StatusForbidden,
RpcErrorCode_UserCanNotLogIn: http.StatusForbidden,
RpcErrorCode_UserHasAlreadyStartedToLogIn: http.StatusForbidden,
RpcErrorCode_UserHasNotStartedToLogIn: http.StatusForbidden,
RpcErrorCode_UserIdIsNotSet: http.StatusBadRequest,
RpcErrorCode_UserIsAlreadyLoggedIn: http.StatusForbidden,
RpcErrorCode_UserIsNotFound: http.StatusNotFound,
RpcErrorCode_UserPreSessionIsNotFound: http.StatusNotFound,
RpcErrorCode_VerificationCodeGenerator: http.StatusInternalServerError,
RpcErrorCode_VerificationCodeIsNotSet: http.StatusBadRequest,
RpcErrorCode_VerificationCodeIsWrong: http.StatusForbidden,
}
}