1 |
|
2 | import type { Timings } from '@szmarczak/http-timer';
|
3 | import type Options from './options.js';
|
4 | import type { TimeoutError as TimedOutTimeoutError } from './timed-out.js';
|
5 | import type { PlainResponse, Response } from './response.js';
|
6 | import type Request from './index.js';
|
7 | type Error = NodeJS.ErrnoException;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export declare class RequestError<T = unknown> extends Error {
|
13 | input?: string;
|
14 | code: string;
|
15 | stack: string;
|
16 | readonly options: Options;
|
17 | readonly response?: Response<T>;
|
18 | readonly request?: Request;
|
19 | readonly timings?: Timings;
|
20 | constructor(message: string, error: Partial<Error & {
|
21 | code?: string;
|
22 | }>, self: Request | Options);
|
23 | }
|
24 | /**
|
25 | An error to be thrown when the server redirects you more than ten times.
|
26 | Includes a `response` property.
|
27 | */
|
28 | export declare class MaxRedirectsError extends RequestError {
|
29 | readonly response: Response;
|
30 | readonly request: Request;
|
31 | readonly timings: Timings;
|
32 | constructor(request: Request);
|
33 | }
|
34 | /**
|
35 | An error to be thrown when the server response code is not 2xx nor 3xx if `options.followRedirect` is `true`, but always except for 304.
|
36 | Includes a `response` property.
|
37 | */
|
38 | export declare class HTTPError<T = any> extends RequestError<T> {
|
39 | readonly response: Response<T>;
|
40 | readonly request: Request;
|
41 | readonly timings: Timings;
|
42 | constructor(response: PlainResponse);
|
43 | }
|
44 | /**
|
45 | An error to be thrown when a cache method fails.
|
46 | For example, if the database goes down or there's a filesystem error.
|
47 | */
|
48 | export declare class CacheError extends RequestError {
|
49 | readonly request: Request;
|
50 | constructor(error: Error, request: Request);
|
51 | }
|
52 | /**
|
53 | An error to be thrown when the request body is a stream and an error occurs while reading from that stream.
|
54 | */
|
55 | export declare class UploadError extends RequestError {
|
56 | readonly request: Request;
|
57 | constructor(error: Error, request: Request);
|
58 | }
|
59 | /**
|
60 | An error to be thrown when the request is aborted due to a timeout.
|
61 | Includes an `event` and `timings` property.
|
62 | */
|
63 | export declare class TimeoutError extends RequestError {
|
64 | readonly request: Request;
|
65 | readonly timings: Timings;
|
66 | readonly event: string;
|
67 | constructor(error: TimedOutTimeoutError, timings: Timings, request: Request);
|
68 | }
|
69 | /**
|
70 | An error to be thrown when reading from response stream fails.
|
71 | */
|
72 | export declare class ReadError extends RequestError {
|
73 | readonly request: Request;
|
74 | readonly response: Response;
|
75 | readonly timings: Timings;
|
76 | constructor(error: Error, request: Request);
|
77 | }
|
78 | /**
|
79 | An error which always triggers a new retry when thrown.
|
80 | */
|
81 | export declare class RetryError extends RequestError {
|
82 | constructor(request: Request);
|
83 | }
|
84 | /**
|
85 | An error to be thrown when the request is aborted by AbortController.
|
86 | */
|
87 | export declare class AbortError extends RequestError {
|
88 | constructor(request: Request);
|
89 | }
|
90 | export {};
|