Skip to content
Myr

KyError.ts

This file

Path

source/errors/KyError.ts

14 lines · 682 bytes · TypeScript

Last changed by

Add `maxResponseSize` optionSindre Sorhusbefore adoption0d59458

History of this file

Take it

Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b

line 1why, one step back
1/**

Add `maxResponseSize` optionSindre Sorhusbefore adoption0d59458

line 2why, one step back
2Base class for all Ky-specific errors. `HTTPError`, `NetworkError`, `TimeoutError`, `ResponseSizeError`, and `ForceRetryError` extend this class.

Readme tweaksSindre Sorhusbefore adoption7f2eade

lines 3–6why, one step back
3
4You can use `instanceof KyError` to check if an error originated from Ky, or use the `isKyError()` type guard for cross-realm compatibility and TypeScript type narrowing.56Note: `SchemaValidationError` is intentionally not considered a Ky error. `KyError` covers failures in Ky's HTTP lifecycle (bad status, timeout, retry), while schema validation errors originate from the user-provided schema, not from Ky itself.

Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b

lines 7–9why, one step back
7*/
8export class KyError extends Error {9 override name = 'KyError';

Various tweaksSindre Sorhusbefore adoption0dd9522

lines 10–13why, one step back
10
11 get isKyError(): true {12 return true;13 }

Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b

line 14why, one step back
14}