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 fileTake it
Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b
line 1why, one step back1/**Add `maxResponseSize` optionSindre Sorhusbefore adoption0d59458
line 2why, one step back2Base class for all Ky-specific errors. `HTTPError`, `NetworkError`, `TimeoutError`, `ResponseSizeError`, and `ForceRetryError` extend this class.Readme tweaksSindre Sorhusbefore adoption7f2eade
lines 3–6why, one step back34You 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 back7*/8export class KyError extends Error {9 override name = 'KyError';Various tweaksSindre Sorhusbefore adoption0dd9522
lines 10–13why, one step back1011 get isKyError(): true {12 return true;13 }Make `beforeError` hook receive all errors (#829)Sindre Sorhusbefore adoption101c74b
line 14why, one step back14}