Nodejs: How to catch an exception from middleware?
Ah, ok, got it. The trick is to leave away the development errorHandler
app.configure('development', function() { // app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));});
It seems to swallow calls to app.error, so now this works:
app.error(function(err, req, res, next) { sys.puts("APP.ERROR:" + sys.inspect(err)); next(err);});
This shows the correct error instead of [object Object]