New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

standard-http-error

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

standard-http-error

Standard HTTP error class. Proper serialization, no bloat. Extensible.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
94K
increased by193.32%
Maintainers
1
Weekly downloads
 
Created

What is standard-http-error?

The standard-http-error npm package provides a simple way to create and manage HTTP errors in Node.js applications. It standardizes the creation of HTTP error objects, making it easier to handle errors consistently across your application.

What are standard-http-error's main functionalities?

Creating HTTP Error Instances

This feature allows you to create an instance of an HTTP error with a specific status code and message. The code sample demonstrates creating a 404 Not Found error.

const HttpError = require('standard-http-error');
const error = new HttpError(404, 'Not Found');
console.log(error.status); // 404
console.log(error.message); // 'Not Found'

Custom Error Messages

You can customize the error message for any HTTP status code. The code sample shows how to create a 500 Internal Server Error with a custom message.

const HttpError = require('standard-http-error');
const error = new HttpError(500, 'Internal Server Error');
console.log(error.status); // 500
console.log(error.message); // 'Internal Server Error'

Default Error Messages

If no custom message is provided, the package uses default messages for standard HTTP status codes. The code sample demonstrates creating a 400 Bad Request error with the default message.

const HttpError = require('standard-http-error');
const error = new HttpError(400);
console.log(error.status); // 400
console.log(error.message); // 'Bad Request'

Other packages similar to standard-http-error

Keywords

FAQs

Package last updated on 04 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc