Skip to content
Myr

app.js

This file

Path

examples/error/app.js

25 lines · 697 bytes · JavaScript

Last changed by

Updated examples to use express.<middleware>Tj Holowaychukbefore adoption90a1a2f

History of this file

Take it

The walk stopped after 200 commits: lines older than 4ee5c59 point at it.

Misc refactoring of github exampleTj Holowaychukbefore adoption4ee5c59

lines 1–5why, one step back
1
2/**3 * Module dependencies.4 */5

Updated examples to use express.<middleware>Tj Holowaychukbefore adoption90a1a2f

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

Misc refactoring of github exampleTj Holowaychukbefore adoption4ee5c59

lines 7–14why, one step back
7
8var app = express.createServer();910app.get('/', function(req, res){11 // Caught and passed down to the errorHandler middleware12 throw new Error('something broke!');13});14

Updated examplesTj Holowaychukbefore adoptionf60bcca

line 15why, one step back
15app.get('/next', function(req, res, next){

Misc refactoring of github exampleTj Holowaychukbefore adoption4ee5c59

lines 16–22why, one step back
16 // We can also pass exceptions to next()
17 next(new Error('oh no!'))18});1920// The errorHandler middleware in this case will dump exceptions to stderr21// as well as show the stack trace in responses, currently handles text/plain,22// text/html, and application/json responses to aid in development

Updated examples to use express.<middleware>Tj Holowaychukbefore adoption90a1a2f

line 23why, one step back
23app.use('/', express.errorHandler({ dumpExceptions: true, showStack: true }));

Misc refactoring of github exampleTj Holowaychukbefore adoption4ee5c59

lines 24–25why, one step back
24
25app.listen(3000);