http-browserify
http-browserify copied to clipboard
How to catch ECONNREFUSED?
In Node.js, when using the request function of the http module, you can subscribe to the error events of the returned object, such as:
var http = require('http');
var req = http.request('aaa.bbb.ccc.ddd', function (res) {
console.log(res.statusCode);
});
req.on('error', function (err) {
console.log('###');
});
req.end();
When I run this with a non-existent IP on Node.js, everything is fine, and the result is ### printed to the console.
When I run this using http-browserify in Chrome, I get an uncaught exception. Am I doing something wrong?
I'm having the same issue. Any resolution to this?
Unfortunately, I don't have one :-(
I believe you will have to listen to the window for these uncaught network errors and decide what to do with them.