fastify-http-exceptions is a small, opinionated Fastify plugin and core library for typed HTTP exceptions. It lets you throw HTTP exceptions with structured error payloads in your route handlers and have them automatically converted into proper Fastify responses. The core utilities are framework-agnostic; the Fastify plugin was created out of real-world need to simplify error handling in larger APIs.
See packages/fastify-http-exceptions/README.md for full documentation.
This repository is a small monorepo:
packages/fastify-http-exceptions: core library and Fastify plugin.demos/basic-example: a demo Fastify app that uses the plugin.
You generally only need the published fastify-http-exceptions package, but the demo and tests live here as reference.
pnpm install
pnpm dev
pnpm tsc
pnpm build
pnpm lint # oxlint
pnpm lint:fix
pnpm format # oxfmt
pnpm test # vitestTo run the demo app: pnpm dev (all dev targets in parallel) or pnpm start (basic-example). See CONTRIBUTING.md for the issue/PR workflow and RELEASING.md for release setup. Releases are published by manually running the Release workflow on main.
Ben Houston, Sponsored by Land of Assets