Browse Source

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>
v1.8.0-commit
Evan Lucas 10 years ago
committed by Evan Lucas
parent
commit
b1a208c83c
  1. 24
      lib/net.js
  2. 6
      lib/util.js

24
lib/net.js

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

6
lib/util.js

@ -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;
if (port && port > 0) {
details = address + ':' + port;

Loading…
Cancel
Save