-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorMessages.ts
187 lines (177 loc) · 4.86 KB
/
ErrorMessages.ts
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/* Error object definition. */
import { StatusCodes } from 'http-status-codes'
export interface IError {
Code: number
Message: string
Details?: string
HTTPStatus: number
}
/* General response messages */
export const ErrorMessages = {
Unknown: {
Code: 999,
Message: 'Unknown Error',
HTTPStatus: 999,
},
// Entity Group
InvalidEntity: {
Code: 101,
Message: 'Invalid Entity Type',
HTTPStatus: StatusCodes.BAD_REQUEST,
},
InvalidFormat: {
Code: 102,
Message: 'Invalid Format.',
HTTPStatus: StatusCodes.BAD_REQUEST,
},
ConversionInProgress: {
Code: 103,
Message: 'ConversionStillInProgress',
HTTPStatus: StatusCodes.ACCEPTED,
},
EntityAlreadyExists: {
Code: 104,
Message: 'Entity Already Exists',
HTTPStatus: StatusCodes.CONFLICT,
},
EntityDoesNotExist: {
Code: 105,
Message: 'Entity does not exist.',
HTTPStatus: StatusCodes.NOT_FOUND,
},
// Quota
QuotaFull: {
Code: 200,
Message: 'Quota is Full',
HTTPStatus: StatusCodes.REQUEST_TOO_LONG,
},
// Project group
ProjectExists: {
Code: 300,
Message: 'Project already exists',
Details: '<details>',
HTTPStatus: StatusCodes.CONFLICT,
},
ProjectDoesNotExist: {
Code: 301,
Message: 'Project does not exist.',
Details: '<details>',
HTTPStatus: StatusCodes.NOT_FOUND,
},
// Auth group
Unauthorized: {
Code: 400,
Message: 'Unauthorized',
HTTPStatus: StatusCodes.UNAUTHORIZED,
},
UnauthorizedorInvalid: {
Code: 401,
Message: 'Unauthorized.Mismatching or invalid token.',
HTTPStatus: StatusCodes.UNAUTHORIZED,
},
MismatchingTokenParameter: {
Code: 402,
Message: 'Mismatching Token parameters',
HTTPStatus: StatusCodes.UNAUTHORIZED,
},
IncorrectKey: {
Code: 403,
Message: 'Incorrect key or password',
HTTPStatus: StatusCodes.FORBIDDEN,
},
// Generic
InternalServerError: {
Code: 500,
Message: 'Internal Server Error',
Details: '<details>',
HTTPStatus: StatusCodes.INTERNAL_SERVER_ERROR,
},
ResourceExists: {
Code: 501,
Message: 'Resource already exists',
Details: '<details>',
HTTPStatus: StatusCodes.CONFLICT,
},
ResourceDoesNotExist: {
Code: 502,
Message: 'Resource does not exist',
Details: '<details>',
HTTPStatus: StatusCodes.NOT_FOUND,
},
// Conversions
CancelException: {
Code: 503,
Message: 'Error canceling exception.',
Details: '<details>',
HTTPStatus: StatusCodes.INTERNAL_SERVER_ERROR,
},
//Database group
DatabaseOperationError: {
Code: 601,
Message: 'Unhandled error during database operation',
Details: '<details>',
HTTPStatus: StatusCodes.INTERNAL_SERVER_ERROR,
},
//Organization group
OrganizationExists: {
Code: 701,
Message: 'Organzanition already exists',
Details: '<details>',
HTTPStatus: StatusCodes.CONFLICT,
},
OrganizationDoesNotExist: {
Code: 702,
Message: 'Organization does not exist',
Details: '<details>',
HTTPStatus: StatusCodes.NOT_FOUND,
},
MemberExists: {
Code: 703,
Message: 'Organzanition member already exists',
Details: '<details>',
HTTPStatus: StatusCodes.CONFLICT,
},
MemberDoesNotExist: {
Code: 704,
Message: 'Organzanition member does not exist',
Details: '<details>',
HTTPStatus: StatusCodes.NOT_FOUND,
},
MembersExceed: {
Code: 705,
Message: 'Members limit has been reached',
Details: '<details>',
HTTPStatus: StatusCodes.INTERNAL_SERVER_ERROR,
},
InvalidPermissions: {
Code: 706,
Message: 'Member is not allowed to perform this operation',
Details: '<details>',
HTTPStatus: StatusCodes.FORBIDDEN,
},
InvalidRole: {
Code: 707,
Message: 'The role of the request is not valid',
Details: '<details>',
HTTPStatus: StatusCodes.INTERNAL_SERVER_ERROR,
},
//Users
UserNotFound: {
Code: 801,
Message: 'User not found',
Details: '<details>',
HTTPStatus: StatusCodes.NOT_FOUND,
},
CannotConnectDatabase: {
Code: 802,
Message: 'Cannot connect to database',
Details: '<details>',
HTTPStatus: StatusCodes.INTERNAL_SERVER_ERROR,
},
// Processing
ProcessingNotAllowed: {
Code: 900,
Message: 'It is not possible to process child entities.',
HTTPStatus: StatusCodes.METHOD_NOT_ALLOWED,
},
} satisfies Record<string, IError>