Skip to content
Myr

HTTPError.ts

This file

Path

source/errors/HTTPError.ts

21 lines · 652 bytes · TypeScript

Last changed by

Minor tweaksSindre Sorhusbefore adoption453846e

History of this file

Take it

Move to TypeScript (#330)Olivier Louvignesbefore adoption2d8d68a

lines 1–6why, 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;

Minor tweaksSindre Sorhusbefore adoption453846e

line 7why, one step back
7

Move to TypeScript (#330)Olivier Louvignesbefore adoption2d8d68a

lines 8–14why, one step back
8 constructor(response: Response, request: Request, options: NormalizedOptions) {
9 // Set the message to the status text, such as Unauthorized,10 // with some fallbacks. This message should never be undefined.11 super(12 response.statusText ||13 String(response.status === 0 || response.status ? response.status : 'Unknown response error')14 );

Minor tweaksSindre Sorhusbefore adoption453846e

line 15why, one step back
15

Move to TypeScript (#330)Olivier Louvignesbefore adoption2d8d68a

lines 16–21why, one step back
16 this.name = 'HTTPError';
17 this.response = response;18 this.request = request;19 this.options = options;20 }21}