app.js
This file
Path
examples/error/app.js
26 lines · 739 bytes · JavaScript
Last changed by
Added exception exampleTj Holowaychukbefore adoptioncaed07d
History of this fileTake it
Added exception exampleTj Holowaychukbefore adoptioncaed07d
lines 1–26why, one step back12/**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});1516app.get('/next', function(req, res, params, next){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);