deno.land / x / feathers@v5.0.0-pre.29 / _errors / mod.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// DO NOT MODIFY - generated from packages/errors/src/index.ts
export interface FeathersErrorJSON { name: string; message: string; code: number; className: string; data?: any; errors?: any;}
export type DynamicError = Error & { [key: string]: any };export type ErrorMessage = string | DynamicError | { [key: string]: any } | any[];
interface ErrorProperties extends Omit<FeathersErrorJSON, 'message'> { type: string;}
export class FeathersError extends Error { readonly type: string; readonly code: number; readonly className: string; readonly data: any; readonly errors: any;
constructor (err: ErrorMessage, name: string, code: number, className: string, _data: any) { let msg = typeof err === 'string' ? err : 'Error'; const properties: ErrorProperties = { name, code, className, type: 'FeathersError' };
if (Array.isArray(_data)) { properties.data = _data; } else if (typeof err === 'object' || _data !== undefined) { const { message, errors, ...rest } = typeof err === 'object' ? err : _data;
msg = message || msg; properties.errors = errors; properties.data = rest; }
super(msg); Object.assign(this, properties); }
toJSON () { const result: FeathersErrorJSON = { name: this.name, message: this.message, code: this.code, className: this.className };
if (this.data !== undefined) { result.data = this.data; }
if (this.errors !== undefined) { result.errors = this.errors; }
return result; }}
export class BadRequest extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'BadRequest', 400, 'bad-request', data); }}
// 401 - Not Authenticatedexport class NotAuthenticated extends FeathersError{ constructor (message?: ErrorMessage, data?: any) { super(message, 'NotAuthenticated', 401, 'not-authenticated', data); }}
// 402 - Payment Errorexport class PaymentError extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'PaymentError', 402, 'payment-error', data); }}
// 403 - Forbiddenexport class Forbidden extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'Forbidden', 403, 'forbidden', data); }}
// 404 - Not Foundexport class NotFound extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'NotFound', 404, 'not-found', data); }}
// 405 - Method Not Allowedexport class MethodNotAllowed extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'MethodNotAllowed', 405, 'method-not-allowed', data); }}
// 406 - Not Acceptableexport class NotAcceptable extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'NotAcceptable', 406, 'not-acceptable', data); }}
// 408 - Timeoutexport class Timeout extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'Timeout', 408, 'timeout', data); }}
// 409 - Conflictexport class Conflict extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'Conflict', 409, 'conflict', data); }}
// 410 - Goneexport class Gone extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'Gone', 410, 'gone', data); }}
// 411 - Length Requiredexport class LengthRequired extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'LengthRequired', 411, 'length-required', data); }}
// 422 Unprocessableexport class Unprocessable extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'Unprocessable', 422, 'unprocessable', data); }}
// 429 Too Many Requestsexport class TooManyRequests extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'TooManyRequests', 429, 'too-many-requests', data); }}
// 500 - General Errorexport class GeneralError extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'GeneralError', 500, 'general-error', data); }}
// 501 - Not Implementedexport class NotImplemented extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'NotImplemented', 501, 'not-implemented', data); }}
// 502 - Bad Gatewayexport class BadGateway extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'BadGateway', 502, 'bad-gateway', data); }}
// 503 - Unavailableexport class Unavailable extends FeathersError { constructor (message?: ErrorMessage, data?: any) { super(message, 'Unavailable', 503, 'unavailable', data); }}
export interface Errors { FeathersError: FeathersError; BadRequest: BadRequest; NotAuthenticated: NotAuthenticated; PaymentError: PaymentError; Forbidden: Forbidden; NotFound: NotFound; MethodNotAllowed: MethodNotAllowed; NotAcceptable: NotAcceptable; Timeout: Timeout; Conflict: Conflict; LengthRequired: LengthRequired; Unprocessable: Unprocessable; TooManyRequests: TooManyRequests; GeneralError: GeneralError; NotImplemented: NotImplemented; BadGateway: BadGateway; Unavailable: Unavailable; 400: BadRequest; 401: NotAuthenticated; 402: PaymentError; 403: Forbidden; 404: NotFound; 405: MethodNotAllowed; 406: NotAcceptable; 408: Timeout; 409: Conflict; 411: LengthRequired; 422: Unprocessable; 429: TooManyRequests; 500: GeneralError; 501: NotImplemented; 502: BadGateway; 503: Unavailable;}
export const errors = { FeathersError, BadRequest, NotAuthenticated, PaymentError, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, Timeout, Conflict, LengthRequired, Unprocessable, TooManyRequests, GeneralError, NotImplemented, BadGateway, Unavailable, 400: BadRequest, 401: NotAuthenticated, 402: PaymentError, 403: Forbidden, 404: NotFound, 405: MethodNotAllowed, 406: NotAcceptable, 408: Timeout, 409: Conflict, 410: Gone, 411: LengthRequired, 422: Unprocessable, 429: TooManyRequests, 500: GeneralError, 501: NotImplemented, 502: BadGateway, 503: Unavailable}
export function convert (error: any) { if (!error) { return error; }
const FeathersError = (errors as any)[error.name]; const result = FeathersError ? new FeathersError(error.message, error.data) : new Error(error.message || error);
if (typeof error === 'object') { Object.assign(result, error); }
return result;}
feathers
The API and real-time application framework
DocumentationDocumentation
GitHub Repositoryfeathersjs/feathers
GitHub Stars
14344

Version Info

Tagged at
4 months ago

External Dependencies

No external dependencies 🎉