master
TJ Holowaychuk 2013-08-27 20:29:18 -07:00
parent 99895aa215
commit 5cc50ef2c8
1 changed files with 15 additions and 0 deletions

View File

@ -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