diff --git a/docs/api.md b/docs/api.md index df0f94f..7b3aa01 100644 --- a/docs/api.md +++ b/docs/api.md @@ -538,6 +538,14 @@ throw err; By default outputs all errors to stderr unless __NODE_ENV__ is "test". To perform custom error-handling logic such as centralized logging you can add an "error" event listener: +```js +app.on('error', function(err){ + log.error('server error', err); +}); +``` + + If an error in the req/res cycle and it is _not_ possible to respond to the client, the `Context` instance is also passed: + ```js app.on('error', function(err){ log.error('server error', err); diff --git a/lib/context.js b/lib/context.js index fda7cdd..27e6a1d 100644 --- a/lib/context.js +++ b/lib/context.js @@ -1,3 +1,4 @@ + /** * Module dependencies. */