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