1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export declare class HttpError extends Error {
|
12 | response: Response;
|
13 | status: number;
|
14 | constructor(response: Response);
|
15 | }
|
16 | /**
|
17 | * Problem extends the HttpError object. If a server emits a HTTP error, and
|
18 | * the response body's content-type is application/problem+json.
|
19 | *
|
20 | * application/problem+json is defined in RFC7807 and provides a standardized
|
21 | * way to describe error conditions by a HTTP server.
|
22 | *
|
23 | * @constructor
|
24 | * @param {Response} response
|
25 | * @param {object} problemBody
|
26 | */
|
27 | export declare class Problem extends HttpError {
|
28 | body: {
|
29 | title?: string;
|
30 | };
|
31 | constructor(response: Response, problemBody: object);
|
32 | }
|
33 | /**
|
34 | * This function creates problems, not unlike the the author of this file.
|
35 | *
|
36 | * It takes a Fetch Response object, and returns a HttpError. If the HTTP
|
37 | * response has a type of application/problem+json it will return a Problem
|
38 | * object.
|
39 | *
|
40 | * Because parsing the response might be asynchronous, the function returns
|
41 | * a Promise resolving in either object.
|
42 | */
|
43 | export default function problemFactory(response: Response): Promise<HttpError | Problem>;
|