deno.land / x / ky@v0.31.3 / source / errors / HTTPError.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type {NormalizedOptions} from '../types/options.js';
// eslint-lint-disable-next-line @typescript-eslint/naming-conventionexport class HTTPError extends Error { public response: Response; public request: Request; public options: NormalizedOptions;
constructor(response: Response, request: Request, options: NormalizedOptions) { const code = (response.status || response.status === 0) ? response.status : ''; const title = response.statusText || ''; const status = `${code} ${title}`.trim(); const reason = status ? `status code ${status}` : 'an unknown error';
super(`Request failed with ${reason}`);
this.name = 'HTTPError'; this.response = response; this.request = request; this.options = options; }}
ky

Version Info

Tagged at
a year ago