wrap-error-handler

1.0.0 • Public • Published

wrap-error-handler

Utility used to catch unhandled exceptions in express route handlers

Installation

Using npm:

npm install --save wrap-error-handler

Usage

import wrapErrorHandler from "wrap-error-handler";
 
function routeHandler(req, res, next) {
  const result = doSomethingThatMayThrowAnError();
  res.json(result);
}
 
const router = express.Router();
 
router.get('/', wrapErrorHandler(routeHandler));

API

wrapErrorHandler(fn)

fn

Type: function

Express handler function to wrap.

Development

Install dependencies

npm install

Run linter

npm run lint

Run tests

npm run tests

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    5
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    5

Package Sidebar

Install

npm i wrap-error-handler

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

4.63 kB

Total Files

5

Last publish

Collaborators

  • pooleparty