HTTPError.ts
This file
Path
source/errors/HTTPError.ts
25 lines · 891 bytes · TypeScript
Last changed by
Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b
History of this fileTake it
The walk stopped after 200 commits: lines older than f34fb1f point at it.
Fix response details getting lost when using `onDownloadProgress` (#441)Yixuan Xubefore adoptionf34fb1f
line 1why, one step back1import type {NormalizedOptions} from '../types/options.js';Use KyRequest and KyResponse types in errors (#610)Mark Fultonbefore adoption8e171f5
lines 2–3why, one step back2import type {KyRequest} from '../types/request.js';3import type {KyResponse} from '../types/response.js';Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b
line 4why, one step back4import {KyError} from './KyError.js';Fix response details getting lost when using `onDownloadProgress` (#441)Yixuan Xubefore adoptionf34fb1f
line 5why, one step back5Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b
lines 6–11why, one step back6export class HTTPError<T = unknown> extends KyError {7 override name = 'HTTPError' as const;8 response: KyResponse<T>;9 request: KyRequest;10 options: NormalizedOptions;11 data: T | string | undefined;Fix response details getting lost when using `onDownloadProgress` (#441)Yixuan Xubefore adoptionf34fb1f
lines 12–14why, one step back1213 constructor(response: Response, request: Request, options: NormalizedOptions) {14 const code = (response.status || response.status === 0) ? response.status : '';Minor tweak (#745)Hichembefore adoptionb9df6cf
line 15why, one step back15 const title = response.statusText ?? '';Fix response details getting lost when using `onDownloadProgress` (#441)Yixuan Xubefore adoptionf34fb1f
lines 16–18why, one step back16 const status = `${code} ${title}`.trim();17 const reason = status ? `status code ${status}` : 'an unknown error';18Add request method and URL to error messages (#595)Seth Holladaybefore adoption36d0bd3
line 19why, one step back19 super(`Request failed with ${reason}: ${request.method} ${request.url}`);Fix response details getting lost when using `onDownloadProgress` (#441)Yixuan Xubefore adoptionf34fb1f
lines 20–25why, one step back2021 this.response = response;22 this.request = request;23 this.options = options;24 }25}