TimeoutError.ts

ky · integration

Defines TimeoutError class extending KyError, thrown on HTTP request timeout with request property.

import type {KyRequest} from '../types/request.js';
import {KyError} from './KyError.js';

/**
Error thrown when the request times out. It has a `request` property with the `Request` object.
*/
export class TimeoutError extends KyError {
	override name = 'TimeoutError' as const;
	request: KyRequest;

	constructor(request: Request) {
		super(`Request timed out: ${request.method} ${request.url}`);
		this.request = request;
	}
}

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key