Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add "verbose errors" option to error-pages example

  • Loading branch information...
commit 3c5ad753b6b65eb5b7ee572cb7fcaf516c752cb3 1 parent dd338b5
@tj tj authored
View
13 examples/error-pages/index.js
@@ -6,9 +6,21 @@ var express = require('../../')
, app = module.exports = express()
, silent = 'test' == process.env.NODE_ENV;
+// general config
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
+// our custom "verbose errors" setting
+// which we can use in the templates
+// via settings['verbose errors']
+app.enable('verbose errors');
+
+// disable them in production
+// use $ NODE_ENV=production node examples/error-pages
+if ('production' == app.settings.env) {
+ app.disable('verbose errors');
+}
+
app.use(express.favicon());
silent || app.use(express.logger('dev'));
@@ -31,7 +43,6 @@ app.use(app.router);
// $ curl http://localhost:3000/notfound -H "Accept: text/plain"
app.use(function(req, res, next){
- // apply the 404 status code to all forms of accept headers
res.status(404);
// respond with html page
View
5 examples/error-pages/views/500.jade
@@ -7,4 +7,7 @@ extends error
block content
h1 Error: #{error.message}
- pre= error.stack
+ if settings['verbose errors']
+ pre= error.stack
+ else
+ p An error ocurred!
Please sign in to comment.
Something went wrong with that request. Please try again.