Closed binarykitchen closed 11 years ago
you have to delegate errors with next(err)
in async callbacks, for example:
db.find(id, function(err){
if (err) throw err;
})
cannot be caught by express, while the following can be:
db.find(id, function(err){
if (err) return next(err);
})
so something must be throwing instead of delegating
ah, thanks! this is very important information. can you add this somewhere in the guide? http://expressjs.com/guide.html
one last question: what if I'm creating new exceptions inside async callbacks?
like this:
throw new Exception('errrrrror');
should I use
next(new Exception('errrrrror'));
instead?
and um, does this rule apply to all async callbacks or only those within express routes?
for example async callbacks within socket.io?
yup it applies to all of node really, one of node's major codesmells
all of node? ouch!
is there an ongoing discussion somewhere else about this smell?
Hello guys
I've googled everywhere about my problem without success so I'm trying here to get some help.
In my code, express does not show the 500 error page when an error happens but is logged within
process.on('uncaughtException')
.Here are the relevant parts of my code:
Then somewhere in the route /clean an error is thrown and caught in
process.on('uncaughtException')
but is never rendered as 500 within express. Why?