-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to let exceptions bubble up instead of passing to finalhandler #2707
Comments
Are you talking about getting printed to your web browser, or to the console you are running Node.js on? |
it does both. I think you just addressed this question on finalhandler issues. Does that answer stand? |
basically i'm using |
The main two configurations are the following: // don't print errors on your node console window
app.set('env', 'test')
// don't print errors to your web browser
app.set('env', 'production') By default Express assumes development mode, which is what causes the stack traces to head to your web browser. Also by default, Express will dump stack traces to your STDERR handle, which is standard when running the server and redirecting STDERR to an error log (as in
Yes, it does :) especially if you want it to be extremely configurable :) Another thing you can do is the following to use var express = require('express')
var finalhander = require('finalhandler')
var http = require('http')
var app = express()
// declare things on app
var server = http.createServer(function (req, res) {
app(req, res, finalhandler(req, res, {
env: 'production', // no stack traces; option name will be better in 1.0
onerror: function (err) {
throw err; // rethrow to your uncaughtException handler, but i _highly_ don't suggest this
}
}))
})
server.listen(3000) |
thanks again @dougwilson |
I'm trying to do some exception handling in my app built on express and it's being problematic that every time I throw an exception it gets printed to the screen.
Is this configurable?
The text was updated successfully, but these errors were encountered: