Registry / http-networking / ono-http

ono-http

JSON →
library0.2.0jsnpmunverified

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-http
INSTALL
IMPORT
SIG · ONO-HTTP
O
ono-http
http-networkingjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

httpError
import { httpError } from 'ono-http'
const httpError = require('ono-http')
ESM-only package; no default export.
createErrorClass
import { createErrorClass } from 'ono-http'
Used to create custom HTTP error subclasses.
OnoHttpError
import { OnoHttpError } from 'ono-http'
import OnoHttpError from 'ono-http'
Named export, not default.

Shows how to create and throw HTTP errors with status codes and format messages, and how to wrap existing errors.

import { httpError } from 'ono-http'; // Throw a 404 Not Found error with a custom message const err = httpError(404, 'Resource %s not found', 'user/123'); throw err; // Wrap an existing error with HTTP status const original = new Error('Database connection failed'); const wrapped = httpError(500, original); throw wrapped;
Debug
Known issues
breakingPackage is v0.2.0 - API may change in future versions without major semver bump
fix
Pin exact version in package.json
affects: >=0.0.0
gotchahttpError expects (statusCode, message, ...args) or (statusCode, innerError) - do not mix both in one call
fix
Use separate httpError calls or ono for combined messages with inner errors
affects: >=0.0.0
deprecatedcreateErrorClass may be removed in future versions; prefer using httpError directly
fix
Use httpError(statusCode, message) for simple cases
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: OnoHttpError is not a constructor
Attempting to use new OnoHttpError() directly, but it's a named export not a constructor
fix
Import { OnoHttpError } and use it as a base class: class MyError extends OnoHttpError {}
Error: Expected a numeric HTTP status code, got "404"
Passing status code as string instead of number
fix
httpError(404, 'Not Found') - use integer
Cannot find module 'ono-http'
Missing ono peer dependency
fix
npm install ono ono-http
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
onorequiredCore dependency for error creation and formatting
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
ono-http — npm install ono-http · libregistry