Skip to content
Myr

app.js

This file

Path

examples/error/app.js

26 lines · 731 bytes · JavaScript

Last changed by

Updated examplesTj Holowaychukbefore adoptionf60bcca

History of this file

Take it

The walk stopped after 200 commits: lines older than 63d02f1 point at it.

Install docsTj Holowaychukbefore adoption63d02f1

lines 1–15why, one step back
1
2/**3 * Module dependencies.4 */56var express = require('./../../lib/express'),7 connect = require('connect');89var app = express.createServer();1011app.get('/', function(req, res){12 // Caught and passed down to the errorHandler middleware13 throw new Error('something broke!');14});15

Updated examplesTj Holowaychukbefore adoptionf60bcca

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

Install docsTj Holowaychukbefore adoption63d02f1

lines 17–26why, one step back
17 // We can also pass exceptions to next()
18 next(new Error('oh no!'))19});2021// The errorHandler middleware in this case will dump exceptions to stderr22// as well as show the stack trace in responses, currently handles text/plain,23// text/html, and application/json responses to aid in development24app.use('/', connect.errorHandler({ dumpExceptions: true, showStack: true }));2526app.listen(3000);