API REFERENCE
Errors
import { HttpError, NotFoundError, MethodNotAllowedError, InternalServerError, } from '@rasenganjs/futon';
A small HTTP-status-bearing error hierarchy. See Error Handling for how these interact with app.onError() and app.notFound().
HttpError
class HttpError extends Error { status: number; constructor(status: number, message?: string); }
Base class. message defaults to a standard reason phrase for the given status (e.g. 404 → "Not Found") when omitted, falling back to "Unknown Error" for unrecognized codes.
Not auto-mapped to a response
Futon does not automatically turn a thrown HttpError into a response with
the matching status — your onError handler needs to check error instanceof HttpError and read error.status itself.
Built-in Subclasses
class NotFoundError extends HttpError { constructor(message?: string); // status 404, default "Not Found" } class MethodNotAllowedError extends HttpError { constructor(message?: string); // status 405, default "Method Not Allowed" } class InternalServerError extends HttpError { constructor(message?: string); // status 500, default "Internal Server Error" }
import { json, HttpError } from '@rasenganjs/futon'; app.onError(async (error, ctx) => { if (error instanceof HttpError) { return json({ error: error.message }, { status: error.status }); } return json({ error: 'Internal Server Error' }, { status: 500 }); });
Router-generated errors
MethodNotAllowedError's status (405) is what the
Router's automatic method-mismatch
response uses, though the router responds directly rather than throwing this
class.
Hooks
