util: _detailedException to _exceptionWithHostPort

The _detailedException() helper function used to be local to the 'net'
module, but now that it has been moved to 'util' a more descriptive name
is desirable.

PR-URL: https://github.com/iojs/io.js/pull/250
Reviewed-By: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
Evan Lucas 2015-01-08 20:13:56 +01:00 committed by Evan Lucas
parent 3937e8566d
commit b1a208c83c
2 changed files with 17 additions and 13 deletions

View File

@ -38,7 +38,7 @@ var WriteWrap = process.binding('stream_wrap').WriteWrap;
var cluster; var cluster;
var errnoException = util._errnoException; var errnoException = util._errnoException;
var detailedException = util._detailedException; var exceptionWithHostPort = util._exceptionWithHostPort;
function noop() {} function noop() {}
@ -763,7 +763,7 @@ function afterWrite(status, handle, req, err) {
} }
if (status < 0) { if (status < 0) {
var ex = detailedException(status, 'write', req.address, req.port); var ex = exceptionWithHostPort(status, 'write', req.address, req.port);
debug('write failure', ex); debug('write failure', ex);
self._destroy(ex, req.cb); self._destroy(ex, req.cb);
return; return;
@ -809,7 +809,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
err = bind(localAddress, localPort); err = bind(localAddress, localPort);
if (err) { if (err) {
var ex = detailedException(err, 'bind', localAddress, localPort); var ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
self._destroy(ex); self._destroy(ex);
return; return;
} }
@ -841,7 +841,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
ex.localPort = self._sockname.port; ex.localPort = self._sockname.port;
details = ex.localAddress + ':' + ex.localPort; details = ex.localAddress + ':' + ex.localPort;
} }
var ex = detailedException(err, 'connect', address, port, details); var ex = exceptionWithHostPort(err, 'connect', address, port, details);
self._destroy(ex); self._destroy(ex);
} }
} }
@ -1001,11 +1001,11 @@ function afterConnect(status, handle, req, readable, writable) {
ex.localPort = req.localPort; ex.localPort = req.localPort;
details = ex.localAddress + ':' + ex.localPort; details = ex.localAddress + ':' + ex.localPort;
} }
var ex = detailedException(status, var ex = exceptionWithHostPort(status,
'connect', 'connect',
req.address, req.address,
req.port, req.port,
details); details);
self._destroy(ex); self._destroy(ex);
} }
} }
@ -1135,7 +1135,7 @@ Server.prototype._listen2 = function(address, port, addressType, backlog, fd) {
debug('_listen2: create a handle'); debug('_listen2: create a handle');
var rval = createServerHandle(address, port, addressType, fd); var rval = createServerHandle(address, port, addressType, fd);
if (util.isNumber(rval)) { if (util.isNumber(rval)) {
var error = detailedException(rval, 'listen', address, port); var error = exceptionWithHostPort(rval, 'listen', address, port);
process.nextTick(function() { process.nextTick(function() {
self.emit('error', error); self.emit('error', error);
}); });
@ -1152,7 +1152,7 @@ Server.prototype._listen2 = function(address, port, addressType, backlog, fd) {
var err = _listen(self._handle, backlog); var err = _listen(self._handle, backlog);
if (err) { if (err) {
var ex = detailedException(err, 'listen', address, port); var ex = exceptionWithHostPort(err, 'listen', address, port);
self._handle.close(); self._handle.close();
self._handle = null; self._handle = null;
process.nextTick(function() { process.nextTick(function() {
@ -1201,7 +1201,7 @@ function listen(self, address, port, addressType, backlog, fd, exclusive) {
} }
if (err) { if (err) {
var ex = detailedException(err, 'bind', address, port); var ex = exceptionWithHostPort(err, 'bind', address, port);
return self.emit('error', ex); return self.emit('error', ex);
} }

View File

@ -758,7 +758,11 @@ exports._errnoException = function(err, syscall, original) {
}; };
exports._detailedException = function(err, syscall, address, port, additional) { exports._exceptionWithHostPort = function(err,
syscall,
address,
port,
additional) {
var details; var details;
if (port && port > 0) { if (port && port > 0) {
details = address + ':' + port; details = address + ':' + port;