{"id":41266,"library":"http-smart-error","title":"http-smart-error","description":"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.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","error","http","typescript"],"install":[{"cmd":"npm install http-smart-error","lang":"bash","label":"npm"},{"cmd":"yarn add http-smart-error","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-smart-error","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency — http-smart-error is a subclass of SmartError and requires it to be installed separately","package":"smart-error","optional":false}],"imports":[{"note":"Package ships TypeScript types; default export only. In CJS environments, use require('http-smart-error').default","wrong":"const HttpSmartError = require('http-smart-error')","symbol":"HttpSmartError","correct":"import HttpSmartError from 'http-smart-error'"},{"note":"Second argument is custom message; third is custom error code string. All after code are optional.","wrong":"HttpSmartError.create(400, null, null, {})","symbol":"create","correct":"HttpSmartError.create(code, message, codeString, extra)"}],"quickstart":{"code":"import HttpSmartError from 'http-smart-error';\n\n// Create a 400 error with default message\nconst err = HttpSmartError.create(400);\nconsole.log(err.statusCode); // 400\nconsole.log(err.message); // \"Bad request\"\nconsole.log(err.code); // \"ERR_BAD_REQUEST\"\n\n// Create a 403 with custom message and extra data\nconst err2 = HttpSmartError.create(403, 'User has no permissions.', 'no_permission', { missing_permission: 'read.something' });\nconsole.log(err2.message); // \"User has no permissions.\"\nconsole.log(err2.code); // \"ERR_NO_PERMISSION\"\nconsole.log(err2.missing_permission); // \"read.something\"","lang":"typescript","description":"Shows creating HTTP errors with default status messages and custom messages/extras."},"warnings":[{"fix":"npm install smart-error@^3.0.0","message":"V4 introduces peer dependency on smart-error ^3.0.0 — must be installed separately.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"const HttpSmartError = require('http-smart-error').default;","message":"Vanilla require('http-smart-error') returns an object with default export; you must use .default or enable esModuleInterop.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'2021':26 '3.0.0':61 '4.0.1':24 '400':44 'bad':45 'built':34 'built-in':33 'cadenc':31 'code':15,17,40,52 'current':21 'custom':50 'data':55 'differenti':32 'e.g':43 'earlier':28 'error':4,12,51,60,63 'extra':19,54 'field':20 'http':2,11,38,64 'http-smart-error':1 'javascript':62 'low':29 'map':36 'messag':16,42 'peer':57 'provid':5 'releas':25,30 'request':46 'requir':56 'smart':3,59 'smart-error':58 'smarterror':9 'stabl':22 'status':14,39 'subclass':7 'support':48 'typescript':65 'version':23","created_at":"2026-06-04T18:51:34.466561+00:00","updated_at":"2026-06-04T18:51:34.466561+00:00","problems":[{"fix":"Use import or require with .default as shown in imports.","cause":"Using require without .default or mixing CJS/ESM","error":"HttpSmartError is not a constructor"},{"fix":"npm install smart-error@^3.0.0","cause":"Missing peer dependency smart-error","error":"Cannot find module 'smart-error'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"http-smart-error","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}