ky
Version:
Tiny and elegant HTTP client based on the Fetch API
17 lines (14 loc) • 987 B
TypeScript
import type { KyRequest } from '../types/request.js';
import { KyError } from './KyError.js';
/**
Error thrown when a network error occurs during the request (e.g., DNS failure, connection refused, offline). It has a `request` property with the `Request` object. The original error is available via the standard `cause` property.
Network errors are automatically retried (for retriable methods). A connection that drops while a Ky shortcut method like `.json()` is reading the response body is also wrapped in `NetworkError`, but it is not retried because the response has already been received.
Note: Network errors are detected using runtime-specific heuristics. Unrecognized runtimes may produce errors that are not wrapped in `NetworkError`. Use the `shouldRetry` option to handle such cases.
*/
export declare class NetworkError extends KyError {
name: string;
request: KyRequest;
constructor(request: Request, options?: {
cause?: Error | undefined;
});
}