Shoulder.dev Logo Shoulder.dev

The Big Picture - benhall/express-demo - Http-errors

HTTP errors is a popular Node.js module used for creating custom HTTP error objects in frameworks like Express, Koa, and Connect. It simplifies the process of creating and handling HTTP errors by providing an API for creating error objects with status codes, messages, and custom properties.

The module allows you to create error objects with various status codes, such as 400 (Bad Request), 401 (Unauthorized), 404 (NotFound), and many others. You can also create custom error objects by passing a message, status code, and custom properties to the createError constructor.

HTTP errors provide an isHttpError function to determine if a provided error object is an HttpError instance. Additionally, you can create error objects using named constructors for specific status codes, such as createError.NotFound or createError.InternalServerError.

The module is licensed under the MIT license and has been used in over 3,500 other projects in the npm registry. To install it, run npm i http-errors. For more information, visit the project’s NPM page or GitHub repository.