Skip to content
forked from koajs/error

Error response middleware (text, json, html)

Notifications You must be signed in to change notification settings

dead-horse/error

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-error

Error response middleware for koa supporting:

  • text
  • json
  • html

Installation

$ npm install koa-error

Options

  • template path to template written with swig

Custom templates

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' %}
      <pre>
        <code>
{{stack}}
        </code>
      </pre>
    {% endif %}
    </div>
  </body>
</html>

License

MIT

About

Error response middleware (text, json, html)

Resources

Stars

Watchers

Forks

Packages

No packages published