util,net: move _detailedException into util
authorEvan Lucas <evan@btc.com>
Thu, 8 Jan 2015 00:03:24 +0000 (18:03 -0600)
committerEvan Lucas <bertbelder@gmail.com>
Thu, 8 Jan 2015 19:15:01 +0000 (20:15 +0100)
This allows _detailedException() to be used by both the 'net' and
'dgram' modules to provide more informative error messages.

PR-URL: https://github.com/iojs/io.js/pull/250
Reviewed-By: Bert Belder <bertbelder@gmail.com>
lib/net.js
lib/util.js

index ed80d02..7767b00 100644 (file)
@@ -38,6 +38,7 @@ var WriteWrap = process.binding('stream_wrap').WriteWrap;
 
 var cluster;
 var errnoException = util._errnoException;
+var detailedException = util._detailedException;
 
 function noop() {}
 
@@ -68,26 +69,6 @@ function isPipeName(s) {
   return util.isString(s) && toNumber(s) === false;
 }
 
-// format exceptions
-function detailedException(err, syscall, address, port, additional) {
-  var details;
-  if (port && port > 0) {
-    details = address + ':' + port;
-  } else {
-    details = address;
-  }
-
-  if (additional) {
-    details += ' - Local (' + additional + ')';
-  }
-  var ex = errnoException(err, syscall, details);
-  ex.address = address;
-  if (port) {
-    ex.port = port;
-  }
-  return ex;
-}
-
 exports.createServer = function() {
   return new Server(arguments[0], arguments[1]);
 };
index c022f6f..5f3e59c 100644 (file)
@@ -756,3 +756,23 @@ exports._errnoException = function(err, syscall, original) {
   e.syscall = syscall;
   return e;
 };
+
+
+exports._detailedException = function(err, syscall, address, port, additional) {
+  var details;
+  if (port && port > 0) {
+    details = address + ':' + port;
+  } else {
+    details = address;
+  }
+
+  if (additional) {
+    details += ' - Local (' + additional + ')';
+  }
+  var ex = exports._errnoException(err, syscall, details);
+  ex.address = address;
+  if (port) {
+    ex.port = port;
+  }
+  return ex;
+};