# koa-error-handler2

> Error handler middleware for koa. Inspired by [koa-onerror] and [koa-error]

Latest version **1.0.2** (published 2023-04-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install koa-error-handler2
pnpm add koa-error-handler2
yarn add koa-error-handler2
bun add koa-error-handler2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-04-08 |
| First published | 2023-04-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mazhansheng02 |

## Links

- npm: https://www.npmjs.com/package/koa-error-handler2
- npm.io page: https://npm.io/package/koa-error-handler2

## Recent versions

- 1.0.2 (latest) — 2023-04-08
- 1.0.1 — 2023-04-08
- 1.0.0 — 2023-04-08

## README

## koa-error-handler2

Error handler middleware for koa. Inspired by [koa-onerror] and [koa-error]

### Install

```
npm i koa-error-handler2
```

### Usage

```
koa-error-handler2(options)
```

Options:

- template: {String} default template to render error to html, default `./error.html`.
- all: {Function} if options.all exist, ignore negotiation.
- text: {Function} text error handler.
- json: {Function} json error handler.
- html: {Function} html error handler.
- debug: {Boolean} whether to print error.stack in console.
- alias: {Object} error.status alias.

### Example

```
const koa = require('koa');
const app = koa();

const { errorHandler } = require('koa-error-handler2')

app.use(errorHandler);


app.listen(3000, function () {
  console.log('listening on port 3000.');
});
```

### Test

```
test
```

### License

MIT

---
_Source: https://npm.io/package/koa-error-handler2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
