0.0.2 • Published 11 years ago
koa-error-ejs v0.0.2
koa-error-ejs
Error response middleware for koa supporting:
- text
- json
html
Based on koa-error, adapter to use EJS as view
Installation
$ npm install koa-errorand then copy the default error view to your views folder
$ cp node_modules/koa-error-ejs/error.html views/Options
viewString path to template written with ejs. Defaults to {view.root}/errorlayoutString|Boolean layout to use on error view, or false if none. Defaults to false.customObject specific view for a status code, for example: {404: 'error/not-found'}. Defaults to {}
Custom templates
By using the view option you can override the bland default template,
with the following available local variables:
envctxrequestresponseerrorstackstatuscode
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'){ %>
<pre>
<code>
<%-stack%>
</code>
</pre>
<% } %>
</div>
</body>
</html>License
MIT