-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.ts
342 lines (300 loc) · 9.17 KB
/
errors.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
import { Status } from "./deps.ts";
export abstract class HttpError extends Error {
statusCode: number;
constructor(message: string, statusCode: number, options?: ErrorOptions) {
super(message, options);
this.statusCode = statusCode;
}
}
// 400 Bad Request
export class BadRequestError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Bad Request", Status.BadRequest, options);
}
}
// 401 Unauthorized
export class UnauthorizedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Unauthorized", Status.Unauthorized, options);
}
}
// 402 Payment Required
export class PaymentRequiredError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Payment Required", Status.PaymentRequired, options);
}
}
// 403 Forbidden
export class ForbiddenError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Forbidden", Status.Forbidden, options);
}
}
// 404 Not Found
export class NotFoundError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Not Found", Status.NotFound, options);
}
}
// 405 Method Not Allowed
export class MethodNotAllowedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Method Not Allowed", Status.MethodNotAllowed, options);
}
}
// 406 Not Acceptable
export class NotAcceptableError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Not Acceptable", Status.NotAcceptable, options);
}
}
// 407 Proxy Authentication Required
export class ProxyAuthenticationRequiredError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Proxy Authentication Required",
Status.ProxyAuthRequired,
options
);
}
}
// 408 Request Timeout
export class RequestTimeoutError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Request Timeout", Status.RequestTimeout, options);
}
}
// 409 Conflict
export class ConflictError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Conflict", Status.Conflict, options);
}
}
// 410 Gone
export class GoneError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Gone", Status.Gone, options);
}
}
// 411 Length Required
export class LengthRequiredError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Length Required", Status.LengthRequired, options);
}
}
// 412 Precondition Failed
export class PreconditionFailedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Precondition Failed", Status.PreconditionFailed, options);
}
}
// 413 Payload Too Large
export class PayloadTooLargeError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Payload Too Large",
Status.RequestEntityTooLarge,
options
);
}
}
// 414 URI Too Long
export class URITooLongError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "URI Too Long", Status.RequestURITooLong, options);
}
}
// 415 Unsupported Media Type
export class UnsupportedMediaTypeError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Unsupported Media Type",
Status.UnsupportedMediaType,
options
);
}
}
// 416 Range Not Satisfiable
export class RangeNotSatisfiableError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Range Not Satisfiable",
Status.RequestedRangeNotSatisfiable,
options
);
}
}
// 417 Expectation Failed
export class ExpectationFailedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Expectation Failed", Status.ExpectationFailed, options);
}
}
// 418 I'm a teapot
export class ImATeapotError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "I'm a teapot", Status.Teapot, options);
}
}
// 421 Misdirected Request
export class MisdirectedRequestError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Misdirected Request", Status.MisdirectedRequest, options);
}
}
// 422 Unprocessable Entity
export class UnprocessableEntityError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Unprocessable Entity",
Status.UnprocessableEntity,
options
);
}
}
// 423 Locked
export class LockedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Locked", Status.Locked, options);
}
}
// 424 Failed Dependency
export class FailedDependencyError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Failed Dependency", Status.FailedDependency, options);
}
}
// 425 Too Early
export class TooEarlyError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Too Early", Status.TooEarly, options);
}
}
// 426 Upgrade Required
export class UpgradeRequiredError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Upgrade Required", Status.UpgradeRequired, options);
}
}
// 428 Precondition Required
export class PreconditionRequiredError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Precondition Required",
Status.PreconditionRequired,
options
);
}
}
// 429 Too Many Requests
export class TooManyRequestsError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Too Many Requests", Status.TooManyRequests, options);
}
}
// 431 Request Header Fields Too Large
export class RequestHeaderFieldsTooLargeError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Request Header Fields Too Large",
Status.RequestHeaderFieldsTooLarge,
options
);
}
}
// 451 Unavailable For Legal Reasons
export class UnavailableForLegalReasonsError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Unavailable For Legal Reasons",
Status.UnavailableForLegalReasons,
options
);
}
}
// 500 Internal Server Error
export class InternalServerError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Internal Server Error",
Status.InternalServerError,
options
);
}
}
// 501 Not Implemented
export class NotImplementedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Not Implemented", Status.NotImplemented, options);
}
}
// 502 Bad Gateway
export class BadGatewayError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Bad Gateway", Status.BadGateway, options);
}
}
// 503 Service Unavailable
export class ServiceUnavailableError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Service Unavailable", Status.ServiceUnavailable, options);
}
}
// 504 Gateway Timeout
export class GatewayTimeoutError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Gateway Timeout", Status.GatewayTimeout, options);
}
}
// 505 HTTP Version Not Supported
export class HTTPVersionNotSupportedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "HTTP Version Not Supported",
Status.HTTPVersionNotSupported,
options
);
}
}
// 506 Variant Also Negotiates
export class VariantAlsoNegotiatesError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Variant Also Negotiates",
Status.VariantAlsoNegotiates,
options
);
}
}
// 507 Insufficient Storage
export class InsufficientStorageError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Insufficient Storage",
Status.InsufficientStorage,
options
);
}
}
// 508 Loop Detected
export class LoopDetectedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Loop Detected", Status.LoopDetected, options);
}
}
// 510 Not Extended
export class NotExtendedError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(message || "Not Extended", Status.NotExtended, options);
}
}
// 511 Network Authentication Required
export class NetworkAuthenticationRequiredError extends HttpError {
constructor(message?: string, options?: ErrorOptions) {
super(
message || "Network Authentication Required",
Status.NetworkAuthenticationRequired,
options
);
}
}