koa-handle-error
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

koa-handle-error

npm version CircleCI

Error handler Middleware for Koa@2.x

Installation

npm install koa-handle-error

Usage

IMPORTANT: handleError must register first as Koa middleware!

const Koa = require('koa');
const handleError = require('koa-handle-error');
const app = new Koa();
 
const onError = err => {
  console.error(err);
};
 
app.use(handleError(onError));  // must register first!
app.use(someMiddleware());
app.use(otherMiddleware());

API

handleError(onError: Function): (context: Koa.Context, next: () => Promise) => void

Returns a Koa middleware.

onError will called with the error when some error occured.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i koa-handle-error

Weekly Downloads

11

Version

0.0.5

License

MIT

Last publish

Collaborators

  • axross