Error response middleware for koa supporting:
- text
- json
- html
$ npm install koa-error
template
path to template written with swig
By using the template
option you can override the bland default template,
with the following available local variables:
env
ctx
request
response
error
stack
status
code
Here's an example:
<!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>
{{error}}
</code>
</pre>
<h2>Stack:</h2>
<pre>
<code>
{{stack}}
</code>
</pre>
{% endif %}
</div>
</body>
</html>
MIT