app.js
This file
Path
examples/error/app.js
28 lines · 776 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 2b907e9 point at it.
fixing testsTj Holowaychukbefore adoption2b907e9
lines 1–28why, one step back12// Expose modules in ./support for demo purposes3require.paths.unshift(__dirname + '/../../support');45/**6 * Module dependencies.7 */89var express = require('../../lib/express');1011var app = express.createServer();1213app.get('/', function(req, res){14 // Caught and passed down to the errorHandler middleware15 throw new Error('something broke!');16});1718app.get('/next', function(req, res, next){19 // We can also pass exceptions to next()20 next(new Error('oh no!'))21});2223// The errorHandler middleware in this case will dump exceptions to stderr24// as well as show the stack trace in responses, currently handles text/plain,25// text/html, and application/json responses to aid in development26app.use('/', express.errorHandler({ dump: true, stack: true }));2728app.listen(3000);