From 3937e8566da9eef72072d9b1737cf5859c65b543 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Wed, 7 Jan 2015 18:03:24 -0600 Subject: [PATCH] util,net: move _detailedException into util 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 --- lib/net.js | 21 +-------------------- lib/util.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/net.js b/lib/net.js index ed80d02f322..7767b000862 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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]); }; diff --git a/lib/util.js b/lib/util.js index c022f6f7e22..5f3e59cc641 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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; +};