ono-http (v0.2.0) extends the ono library to create HTTP-specific error objects with status codes and standard HTTP error messages. It allows throwing errors with a status code (e.g., 404) and an optional custom message using printf-style formatting. The library is lightweight, wraps inner errors, and integrates with ono's error formatting. Current version is early (0.x) and not widely adopted; no clear release cadence. Key differentiator: combines ono's structured error throwing with HTTP status codes for server-side applications.
npm install ono-httpVerified import paths — ran on the pinned version, not inferred.
Shows how to create and throw HTTP errors with status codes and format messages, and how to wrap existing errors.
Pin exact version in package.json
Use separate httpError calls or ono for combined messages with inner errors
Use httpError(statusCode, message) for simple cases
Import { OnoHttpError } and use it as a base class: class MyError extends OnoHttpError {}httpError(404, 'Not Found') - use integer
npm install ono ono-http