Skip to content

Instantly share code, notes, and snippets.

@m0ppers
Created June 29, 2015 18:28
Show Gist options
  • Save m0ppers/ae20ccec50326f4b6a0d to your computer and use it in GitHub Desktop.
Save m0ppers/ae20ccec50326f4b6a0d to your computer and use it in GitHub Desktop.
var http = require("http");
var net = require("net");
var installErrorHandling = function(agent) {
agent.createConnection = function(options) {
var socket = net.createConnection(options);
socket.on("error", function(error) {
console.log("GOT ERROR", error, "request options:", options);
});
return socket;
};
}
installErrorHandling(http.globalAgent);
var options = {
hostname: 'localhost',
port: 87,
path: '/neineineine'
};
http.request(options, function(res) {
console.log("GOT RESPONSE", res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment