From a1edb2fe7c197711eca98b08c0eadaca94fd0063 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 31 Aug 2013 09:18:43 -0700 Subject: [PATCH] add docs for error ctx --- docs/api.md | 8 ++++++++ lib/context.js | 1 + 2 files changed, 9 insertions(+) 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. */