Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


Error response middleware (text, json, html)

Subscribe to updates I use error

Statistics on error

Number of watchers on Github 84
Number of open issues 3
Average time to close an issue 7 months
Main language JavaScript
Average time to merge a PR 4 days
Open pull requests 7+
Closed pull requests 3+
Last commit almost 2 years ago
Repo Created almost 6 years ago
Repo Last Updated over 1 year ago
Size 28 KB
Organization / Authorkoajs
Page Updated
Do you use error? Leave a review!
View open issues (3)
View error activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating error for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


Error response middleware for koa supporting:

  • text
  • json
  • html


$ npm install koa-error


  • template path to template written with your template engine
  • engine template engine name passed to consolidate
  • cache cached compiled functions, default: NODE_ENV != 'development'
  • env force a NODE_ENV, default: development
  • accepts mimetypes passed to ctx.accepts, default: [ 'html', 'text', 'json' ]

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 are some examples:

Pug (formerly jade)

  engine: 'pug',
  template: __dirname + '/error.pug'
doctype html
    title= 'Error - ' + status
      h1 Error
      p Looks like something broke!
      if env == 'development'
        h2 Message:
        pre: code= error
        h2 Stack:
        pre: code= stack


  engine: 'nunjucks',
  template: __dirname + '/error.njk'
<!DOCTYPE html>
    <title>Error - {{status}}</title>
    <div id="error">
    <p>Looks like something broke!</p>
    {% if env == 'development' %}
    {% endif %}



error open issues Ask a question     (View All Issues)
  • over 4 years Prevent node's default action when emitting "error"
  • over 5 years stream error
error open pull requests (View All Pulls)
  • Ability to inject other render engines
  • Support other templates besides Swig
  • Koa2 update
  • Update to Koa 2
  • Option to enable stack trace when NODE_ENV is production
  • Added guard for status code
  • Provide original error, which may contain custom properties.
error questions on Stackoverflow (View All Questions)
  • AndroidStudio 15.1 emulator error 'mksdcard.exe' is missing from the SDK tools folder
  • laravel 5 Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist'
  • 'Undefined' text in error messages, popups, headings, titles and loading bar on SuiteCRM installation
  • ZBar Fatal Error
  • Internal Server Error because one cookie is too big
  • Error importing python swift client from notebook
  • Forked Grails VM exited with error grails 2.5.3
  • Angular 2 QuickStart Live-server error
  • Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration'
  • IIS 7.5 = Nested web.config will not override custom error handling set in application level web.config
  • Spring Data PostgreSQL Key already exists error
  • Foursquare API for venue user image error
  • Why won't this Karma/Jasmine test catch a reference error?
  • Java, Illegal Access Error when accessing another class
  • Mysql error while running import script ERROR 1064
  • AngularJS - $injector:modulerr Module Error in angular.js:36
  • "FirebaseError: Invalid authentication credentials provided" error when setting up google sign in on Android
  • Case mismatch error in Symfony 3.0.2
  • Twitter::Error::Unauthorized error which post twit befalf of user in Rails
  • 'NSInvalidArgumentException', reason: '-[ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance error
  • Error : undefined reference
  • MS Access Error 3211 When deleting a temp table
  • Terminology Emotion-Generic Error When Viewing Images
  • I am getting an error in the LOGCAT saying, java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
  • Yii -Class 'frontend\controllers\UserForm' not found error
  • Syntax Error Python: Unexpected Indent
  • Why is my tic tac toe game returning an error? It has something to do with my checkWinner method
  • Build Error: Using Fabric Twitter Login featute Eclipse project buld fails
  • Error handling in ASP .Net MVC
  • get SSL Broken pipe error when try to make push notification
error list of languages used
Other projects in JavaScript