1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export = createHttpError;
|
9 |
|
10 | declare const createHttpError: createHttpError.CreateHttpError & createHttpError.NamedConstructors & {
|
11 | isHttpError: createHttpError.IsHttpError
|
12 | };
|
13 |
|
14 | declare namespace createHttpError {
|
15 | interface HttpError<N extends number = number> extends Error {
|
16 | status: N;
|
17 | statusCode: N;
|
18 | expose: boolean;
|
19 | headers?: {
|
20 | [key: string]: string;
|
21 | } | undefined;
|
22 | [key: string]: any;
|
23 | }
|
24 |
|
25 | type UnknownError = Error | string | number | { [key: string]: any };
|
26 |
|
27 | type HttpErrorConstructor<N extends number = number> = new (msg?: string) => HttpError<N>;
|
28 |
|
29 | type CreateHttpError = <N extends UnknownError>(arg: N, ...rest: UnknownError[]) => HttpError<N extends number ? N : number>;
|
30 |
|
31 | type IsHttpError = (error: unknown) => error is HttpError;
|
32 |
|
33 | type NamedConstructors = {
|
34 | [code: string]: HttpErrorConstructor;
|
35 | HttpError: HttpErrorConstructor;
|
36 | }
|
37 | & Record<'BadRequest' | '400', HttpErrorConstructor<400>>
|
38 | & Record<'Unauthorized' | '401', HttpErrorConstructor<401>>
|
39 | & Record<'PaymentRequired' | '402', HttpErrorConstructor<402>>
|
40 | & Record<'Forbidden' | '403', HttpErrorConstructor<403>>
|
41 | & Record<'NotFound' | '404', HttpErrorConstructor<404>>
|
42 | & Record<'MethodNotAllowed' | '405', HttpErrorConstructor<405>>
|
43 | & Record<'NotAcceptable' | '406', HttpErrorConstructor<406>>
|
44 | & Record<'ProxyAuthenticationRequired' | '407', HttpErrorConstructor<407>>
|
45 | & Record<'RequestTimeout' | '408', HttpErrorConstructor<408>>
|
46 | & Record<'Conflict' | '409', HttpErrorConstructor<409>>
|
47 | & Record<'Gone' | '410', HttpErrorConstructor<410>>
|
48 | & Record<'LengthRequired' | '411', HttpErrorConstructor<411>>
|
49 | & Record<'PreconditionFailed' | '412', HttpErrorConstructor<412>>
|
50 | & Record<'PayloadTooLarge' | '413', HttpErrorConstructor<413>>
|
51 | & Record<'URITooLong' | '414', HttpErrorConstructor<414>>
|
52 | & Record<'UnsupportedMediaType' | '415', HttpErrorConstructor<415>>
|
53 | & Record<'RangeNotSatisfiable' | '416', HttpErrorConstructor<416>>
|
54 | & Record<'ExpectationFailed' | '417', HttpErrorConstructor<417>>
|
55 | & Record<'ImATeapot' | '418', HttpErrorConstructor<418>>
|
56 | & Record<'MisdirectedRequest' | '421', HttpErrorConstructor<421>>
|
57 | & Record<'UnprocessableEntity' | '422', HttpErrorConstructor<422>>
|
58 | & Record<'Locked' | '423', HttpErrorConstructor<423>>
|
59 | & Record<'FailedDependency' | '424', HttpErrorConstructor<424>>
|
60 | & Record<'UnorderedCollection' | '425', HttpErrorConstructor<425>>
|
61 | & Record<'UpgradeRequired' | '426', HttpErrorConstructor<426>>
|
62 | & Record<'PreconditionRequired' | '428', HttpErrorConstructor<428>>
|
63 | & Record<'TooManyRequests' | '429', HttpErrorConstructor<429>>
|
64 | & Record<'RequestHeaderFieldsTooLarge' | '431', HttpErrorConstructor<431>>
|
65 | & Record<'UnavailableForLegalReasons' | '451', HttpErrorConstructor<451>>
|
66 | & Record<'InternalServerError' | '500', HttpErrorConstructor<500>>
|
67 | & Record<'NotImplemented' | '501', HttpErrorConstructor<501>>
|
68 | & Record<'BadGateway' | '502', HttpErrorConstructor<502>>
|
69 | & Record<'ServiceUnavailable' | '503', HttpErrorConstructor<500>>
|
70 | & Record<'GatewayTimeout' | '504', HttpErrorConstructor<504>>
|
71 | & Record<'HTTPVersionNotSupported' | '505', HttpErrorConstructor<505>>
|
72 | & Record<'VariantAlsoNegotiates' | '506', HttpErrorConstructor<506>>
|
73 | & Record<'InsufficientStorage' | '507', HttpErrorConstructor<507>>
|
74 | & Record<'LoopDetected' | '508', HttpErrorConstructor<508>>
|
75 | & Record<'BandwidthLimitExceeded' | '509', HttpErrorConstructor<509>>
|
76 | & Record<'NotExtended' | '510', HttpErrorConstructor<510>>
|
77 | & Record<'NetworkAuthenticationRequire' | '511', HttpErrorConstructor<511>>
|
78 | ;
|
79 | }
|