/** * @group HTTPError * * A custom [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) * subclass that represents an HTTP error to be returned to the user. * * This allows routes to throw specific HTTP errors directly and * {@link FetchRouter} knows how to handle them and turn them into HTTP Responses * * * * You can use well-known errors like below, you can also pass a [BodyInit](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#body) to customise the response body. * * ```js * throw HTTPError.badRequest() * throw HTTPError.unauthorized() * throw HTTPError.notFound() * throw HTTPError.internalServerError() * throw HTTPError.notImplemented() * * // The plan is to add more error well-known codes as they are needed * ``` * * You can also manually construct the error: * * ```js * const teapot = new HTTPError(418, "I'm a teapot"); * ``` */ export declare class HTTPError extends Error { /** * [400 Bad Request](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400) * * ```js * throw HTTPError.badRequest() * ``` */ static badRequest(body?: BodyInit | undefined): HTTPError; /** * [401 Unauthorized](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401) * * ```js * throw HTTPError.unauthorized() * ``` */ static unauthorized(body?: BodyInit | undefined): HTTPError; /** * [404 Not Found](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404) * * ```js * throw HTTPError.notFound() * ``` */ static notFound(body?: BodyInit | undefined): HTTPError; /** * [500 Internal Server Error](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) * * ```js * throw HTTPError.internalServerError() * ``` */ static internalServerError(body?: BodyInit | undefined): HTTPError; /** * [500 Not Implemented](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501) * * ```js * throw HTTPError.notImplemented() * ``` */ static notImplemented(body?: BodyInit | undefined): HTTPError; /** The HTTP status to return ~ [status](https://developer.mozilla.org/en-US/docs/Web/API/Response/status) */ status: number; /** The status text to return ~ [statusText](https://developer.mozilla.org/en-US/docs/Web/API/Response/statusText) */ statusText: string; /** A custom body to send to the client */ body: BodyInit | undefined; /** Extra headers to send to the client */ headers: Headers | undefined; constructor(status?: number, statusText?: string, body?: BodyInit | undefined, headers?: HeadersInit | undefined); /** * Convert the HTTPError into a HTTP `Response` object * taking into account the `status`, `statusText` and `headers` fields on the error. * * ```js * const error = new HTTPError(418, "I'm a teapot"); * * error.toResponse() // Response * ``` */ toResponse(): Response; } //# sourceMappingURL=http-error.d.ts.map