koa-error-mapper is a middleware that handles application errors by mapping them to a custom format.
Status
Installation
Install the package via yarn:
❯ yarn add koa-error-mapper
or via npm:
❯ npm install koa-error-mapper --save
Usage
Mappers
Mappers are responsible for handling errors and normalizing the response. A generic fallback mapper is included in case no custom mapper is available.
The only interface for a mapper is a map() function. A mapper should return undefined if it is not capable or responsible for mapping a specific error. It must return an object with status and body. If not returned on the object, the value on the response will be undefined for precaution. It may also contain a headers property.