Skip to content
Myr

app.js

This file

Path

examples/error/app.js

28 lines · 776 bytes · JavaScript

Last changed by

docsTj Holowaychukbefore adoption6cae1f0

History of this file

Take it

The walk stopped after 200 commits: lines older than 6bb42ff point at it.

shouldTj Holowaychukbefore adoption6bb42ff

line 1why, one step back
1

docsTj Holowaychukbefore adoption6cae1f0

lines 2–4why, one step back
2// Expose modules in ./support for demo purposes
3require.paths.unshift(__dirname + '/../../support');4

shouldTj Holowaychukbefore adoption6bb42ff

lines 5–8why, one step back
5/**
6 * Module dependencies.7 */8

docsTj Holowaychukbefore adoption6cae1f0

line 9why, one step back
9var express = require('../../lib/express');

shouldTj Holowaychukbefore adoption6bb42ff

lines 10–25why, one step back
10
11var 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 development

docsTj Holowaychukbefore adoption6cae1f0

line 26why, one step back
26app.use('/', express.errorHandler({ dump: true, stack: true }));

shouldTj Holowaychukbefore adoption6bb42ff

lines 27–28why, one step back
27
28app.listen(3000);