app.js
This file
Path
examples/error/app.js
28 lines · 776 bytes · JavaScript
Last changed by
docsTj Holowaychukbefore adoption6cae1f0
History of this fileTake it
The walk stopped after 200 commits: lines older than ce2a18f point at it.
master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f
line 1why, one step back1docsTj Holowaychukbefore adoption6cae1f0
lines 2–4why, one step back2// Expose modules in ./support for demo purposes3require.paths.unshift(__dirname + '/../../support');4master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f
lines 5–8why, one step back5/**6 * Module dependencies.7 */8docsTj Holowaychukbefore adoption6cae1f0
line 9why, one step back9var express = require('../../lib/express');master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f
lines 10–13why, one step back1011var app = express.createServer();1213app.get('/', function(req, res){miscTj Holowaychukbefore adoption4f4987e
lines 14–15why, one step back14 // Caught and passed down to the errorHandler middleware15 throw new Error('something broke!');master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f
lines 16–18why, one step back16});1718app.get('/next', function(req, res, next){miscTj Holowaychukbefore adoption4f4987e
lines 19–20why, one step back19 // We can also pass exceptions to next()20 next(new Error('oh no!'))master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f
lines 21–25why, one step back21});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 developmentdocsTj Holowaychukbefore adoption6cae1f0
line 26why, one step back26app.use('/', express.errorHandler({ dump: true, stack: true }));master is 2.0.0-preTj Holowaychukbefore adoptionce2a18f
lines 27–28why, one step back2728app.listen(3000);