Skip to content

HttpError ​

HttpError provides typed constructors for expected HTTP failures.

Constructors ​

ConstructorSignature
BadRequest(message: string) => HttpError
Unauthorized(message: string) => HttpError
Forbidden(message: string) => HttpError
NotFound(message: string) => HttpError
Conflict(message: string) => HttpError
UnprocessableEntity(message: string) => HttpError
InternalServerError(message: string) => HttpError
custom(status: HttpStatus, errorCode: string, message: string) => HttpError
Signatureconst error = HttpError.custom(HttpStatus.TooManyRequests, "rate_limit", "Too many requests");
tyrus
import { HttpError, HttpStatus } from "tyrus:http";

return reply.error(HttpError.NotFound("User not found"));