@celeri/http-error
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published
$ npm install --save @celeri/http-error

Import

ES6 Modules

import { HttpError, errorHandler } from '@celeri/http-error';

CommonJS Modules

const { HttpError, errorHandler } = require('@celeri/http-error');

Usage

// Create error objects to represent what went wrong
const error = new HttpError(404, 'Could not find the requested document');

// Create your middleware with a processor that takes in an HttpError and returns
// a response payload
const errorMiddleware = errorHandler(({ error }) => ({
	error: error.message
}))

Package Sidebar

Install

npm i @celeri/http-error

Weekly Downloads

18

Version

2.0.1

License

ISC

Unpacked Size

7.58 kB

Total Files

14

Last publish

Collaborators

  • celeri