http-smart-error
TypeScript icon, indicating that this package has built-in type declarations

4.0.1 • Public • Published

http-smart-error

Subclass of SmartError for handling http errors.

Installation

npm install http-smart-error --save

Usage

import HttpSmartError from 'http-smart-error';
 
console.log(HttpSmartError.create(400)); // Http error with 400 status code, message "Bad request" and code "ERR_BAD_REQUEST"
 
console.log(HttpSmartError.create(403, 'User has no permissions to do that.', 'no_permission', { missing_permission: 'read.something'})); // Http error with 403 status code, message "User has no permissions to do that.", code "ERR_NO_PERMISSION" and extra field "missing_permission" with "read.something" value.

Migration to V4

  • smart-error module is as peer dependency. It needs to be installed separately.

Readme

Keywords

Package Sidebar

Install

npm i http-smart-error

Weekly Downloads

7

Version

4.0.1

License

MIT

Unpacked Size

18.6 kB

Total Files

7

Last publish

Collaborators

  • zabkwak