You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, I'm playing with errorHandler and having some trouble figuring it out.
Consider the following code:
var connect = require('connect');
var app = connect()
//.use(connect.errorHandler())
.use(function(req, res) {
var x = JSON.stringify(req); // this line will crash
res.write('this is a test');
res.end(req.url);
})
.listen(8080);
When I run this, and visit the page, I get a text/plain stacktrace along with a 500 HTTP error code. So far so good.
BUT when I un-comment the `.use(connect.errorHandler())` I don't see any change in the behavior of the app ... still seeing text/plain stacktrace. Was expecting pretty HTML stacktrace or something?
What's more, if I swap two lines:
.use(function(req, res) {
res.write('this is a test');
var x = JSON.stringify(req); // this line will crash
res.end(req.url);
})
Now the app outputs nothing to the browser at all (but I still see the stack trace in the console.log).
I even threw a couple console.log statements into node_modules/connect/lib/middleware/errorHandler.js to see what's going on but it doesn't appear the code in that middleware ever executes.
I've tried The Google but not finding much in the way of documentation ... can anyone assist?
Thanks!
PS. Apologies for the code formatting ... GFM isn't working for me this morning?
The text was updated successfully, but these errors were encountered:
Hi there, I'm playing with errorHandler and having some trouble figuring it out.
Consider the following code:
var connect = require('connect');
var app = connect()
//.use(connect.errorHandler())
.use(function(req, res) {
var x = JSON.stringify(req); // this line will crash
res.write('this is a test');
res.end(req.url);
})
.listen(8080);
The text was updated successfully, but these errors were encountered: