Skip to content
Myr

HTTPError.ts

This file

Path

source/errors/HTTPError.ts

19 lines · 650 bytes · TypeScript

Last changed by

Move to TypeScript (#330)Olivier Louvignesbefore adoption2d8d68a

History of this file

Take it

Move to TypeScript (#330)Olivier Louvignesbefore adoption2d8d68a

lines 1–19why, one step back
1import type {NormalizedOptions} from '../types/options.js';
23export class HTTPError extends Error {4 public response: Response;5 public request: Request;6 public options: NormalizedOptions;7 constructor(response: Response, request: Request, options: NormalizedOptions) {8 // Set the message to the status text, such as Unauthorized,9 // with some fallbacks. This message should never be undefined.10 super(11 response.statusText ||12 String(response.status === 0 || response.status ? response.status : 'Unknown response error')13 );14 this.name = 'HTTPError';15 this.response = response;16 this.request = request;17 this.options = options;18 }19}