@salsita/koa-error-middleware
v1.1.2
Published
[![NPM version](https://img.shields.io/npm/v/@salsita/koa-error-middleware.svg)](https://www.npmjs.com/package/@salsita/koa-error-middleware) ![Downloads](https://img.shields.io/npm/dm/@salsita/koa-error-middleware.svg?style=flat) ![Licence](https://img.s
Downloads
8
Readme
@salsita/koa-error-middleware
Top level middleware for catching and displaying errors (assumes using error classes from @salsita/errors).
Expects logging function as parameter.
Example:
const winston = require("winston");
const Router = require("koa-router");
const errorMiddleware = require("@salsita/koa-error-middleware");
const formatUserMessage = err =>
process.env.NODE_ENV === "production" ? "Ooops something went wrong" : err.message;
const router = new Router();
router.use(errorMiddleware(winston.log, formatUserMessage));