1.0.4 • Published 1 year ago

@vukovicpavle/orange-http-error v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

🍊 Http error

Http error middleware for express. It is used to handle errors and return them in a standardized format.

Installation

npm install @vukovicpavle/orange-http-error

Usage

import express from "express";
import {
  HttpError,
  httpErrorMiddleware,
} from "@vukovicpavle/orange-http-error";

// ...

const app = express();

// ...

// This route will throw an error
app.get("/", (req, res, next) => {
  next(new HttpError(404, "Not found"));
});

// Error handler after all routes
app.use(httpErrorMiddleware);

// ...

API

HttpError

Http error class. It is used to throw errors in the routes.

Parameters

NameTypeDescriptionRequiredDefault
statusnumberHttp status codetrue
messagestringError messagetrue

httpErrorMiddleware

Http error middleware. It is used to handle errors and return them in a standardized format.

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago