HTTPError.ts
This file
Path
source/errors/HTTPError.ts
21 lines · 652 bytes · TypeScript
Last changed by
Minor tweaksSindre Sorhusbefore adoption453846e
History of this fileTake it
12345678910111213141516171819202122import type {NormalizedOptions} from '../types/options.js';
export class HTTPError extends Error { public response: Response; public request: Request; public options: NormalizedOptions;
constructor(response: Response, request: Request, options: NormalizedOptions) { // Set the message to the status text, such as Unauthorized, // with some fallbacks. This message should never be undefined. super( response.statusText || String(response.status === 0 || response.status ? response.status : 'Unknown response error') );
this.name = 'HTTPError'; this.response = response; this.request = request; this.options = options; }}