From 5cc50ef2c8e2c8b6c83ea8030c102463d871bf93 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 27 Aug 2013 20:29:18 -0700 Subject: [PATCH] docs --- docs/api.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/api.md b/docs/api.md index 1b982c1..d847542 100644 --- a/docs/api.md +++ b/docs/api.md @@ -513,6 +513,21 @@ switch (this.accepts('json', 'html', 'text')) { Request socket object. +## Error handling + + 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); +}); +``` + + When an error occurs _and_ it is still possible to respond to the client, aka no data has been written to the socket, Koa will respond + appropriately with a 500 "Internal Server Error". In either case + an app-level "error" is emitted for logging purposes. + ## Notes ### HEAD support