npm.io
0.6.5 • Published 7 years ago

kane-error

Licence
MIT
Version
0.6.5
Deps
3
Size
32 kB
Vulns
0
Weekly
0

Kane Error

Known Vulnerabilities

Error handler for the Kane API.

Requirements

You need to execute node version 8.x at least (async/await).

Installation

# npm
npm install --save kane-error
# yarn
yarn add kane-error

Usage

Koa middleware

A simple error handler that log unhandled exceptions and send a standard "message" back to the user:

const Koa = require("koa");
const {koaErrorHandler} = require("kane-error");

const app = new Koa();
app.use(koaErrorHandler());
Koa Custom Error

This is an utility object that incorporate the HTTP status to send back to the user:

const {KaneError} = require("kane-error");

throw new KaneError(418, "I'm a teapot!");
Linting

Made using eslint. To enforce rules to be applied, use yarn lint:fix.

Keywords