package
Error reponses (text, json, html) for koa
npm install koa-errorGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 3 packages.
1.4 MB
Includes dependencies.
Error response middleware for koa supporting:
$ npm install koa-errortemplate path to template written with your template engineengine template engine name passed to consolidatecache cached compiled functions, default: NODE_ENV != 'development'env force a NODE_ENV, default: developmentaccepts mimetypes passed to ctx.accepts, default: [ 'html', 'text', 'json' ]By using the template option you can override the bland default template,
with the following available local variables:
envctxrequestresponseerrorstackstatuscodeHere are some examples:
app.use(error({
engine: 'pug',
template: __dirname + '/error.pug'
}));doctype html
html
head
title= 'Error - ' + status
body
#error
h1 Error
p Looks like something broke!
if env == 'development'
h2 Message:
pre: code= error
h2 Stack:
pre: code= stackapp.use(error({
engine: 'nunjucks',
template: __dirname + '/error.njk'
}));<!DOCTYPE html>
<html>
<head>
<title>Error - {{status}}</title>
</head>
<body>
<div id="error">
<h1>Error</h1>
<p>Looks like something broke!</p>
{% if env == 'development' %}
<h2>Message:</h2>
<pre>
<code>
MIT
mattmueller
mattmuelle@gmail.com