Skip to content

koexjs/onerror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

onerror

NPM version Coverage Status Dependencies Build Status license issues

onerror for koa extend.

Install

$ npm install @koex/onerror

Usage

// See more in test
import onerror from '@koex/onerror';

import * as Koa from 'koa';
const app = new Koa();

app.use(onerror());

// fallback
app.use(async (ctx) => {
  const error = new Error('Unauthorized');
  (error as any).status = 401;
  throw error;
});

app.listen(8000, '0.0.0.0', () => {
  console.log('koa server start at port: 8000');
});

Related