Registry / devops / http-smart-error

http-smart-error

JSON →
library4.0.1jsnpmunverified

Provides a subclass of SmartError for HTTP errors with status codes, messages, codes, and extra fields. Current stable version 4.0.1 (released 2021 or earlier). Low release cadence. Differentiator: built-in mapping of HTTP status codes to messages (e.g., 400 → 'Bad request') and support for custom error codes and extra data. Requires peer smart-error ^3.0.0.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Package ships TypeScript types; default export only. In CJS environments, use require('http-smart-error').default

import HttpSmartError from 'http-smart-error'

Second argument is custom message; third is custom error code string. All after code are optional.

HttpSmartError.create(code, message, codeString, extra)

Shows creating HTTP errors with default status messages and custom messages/extras.

import HttpSmartError from 'http-smart-error'; // Create a 400 error with default message const err = HttpSmartError.create(400); console.log(err.statusCode); // 400 console.log(err.message); // "Bad request" console.log(err.code); // "ERR_BAD_REQUEST" // Create a 403 with custom message and extra data const err2 = HttpSmartError.create(403, 'User has no permissions.', 'no_permission', { missing_permission: 'read.something' }); console.log(err2.message); // "User has no permissions." console.log(err2.code); // "ERR_NO_PERMISSION" console.log(err2.missing_permission); // "read.something"
Debug
Known footguns
breakingV4 introduces peer dependency on smart-error ^3.0.0 — must be installed separately.
gotchaVanilla require('http-smart-error') returns an object with default export; you must use .default or enable esModuleInterop.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
2
Resources