Bad idea to pass error messages to the client?
It makes me a bit nervous that mis-configuring my proxy by pointing it at a non-existent target caused it to send the following message to my browser:
An error has occurred: {"stack":"Error: ENOTFOUND, Domain name not found\n at IOWatcher.callback (dns.js:74:15)","message":"ENOTFOUND, Domain name not found","errno":4,"code":"ENOTFOUND"}
I couldn't find a straight-forward way to avoid sending diagnostics to the client. It seems like the default behaviour should be to send a vague 500 error message to the client.
server.proxy.on('proxyError', function (err, req, res){
//here you do whatever you want, like writing in rep an error page, but you have to finish by ending the response...
res.end();
})
It doesn't work in RouterProxy mode (see #120)
Solved my problem - thank you. It still might be worthwhile to change the default behaviour to send a more vague error, in my opinion.
I can see your point of view, but others could argue that obfuscating the error message by default is worse ( since it's hiding information that most people will want to see ).
It's probably better to just show everything by default and just let people hide it if they want.
IMHO :
User is mostly interested in functional error reporting rather than technical one. Even, if you can, thanks to some work, avoid those errors (like trying to call another server when getting ECONNREFUSED), or at least try to, it's better. BTW it takes some time to wrap all of those technical errors for user, and even not to forget all protocols you use (e.g. don"t forget json for your ajax application, and handle those errors gracefully in your app using something like a flash message)
Developers are interested in what happened, why, and how often, so they would like to store those errors with as much details as possible or even send them by email/xmpp/irc to the team, so error hooks are important here)