summaryrefslogtreecommitdiff
path: root/lib/dns.js
diff options
context:
space:
mode:
authorKenan Sulayman <kenan@sly.mn>2014-02-07 18:18:27 +0100
committerFedor Indutny <fedor.indutny@gmail.com>2014-02-09 13:37:50 +0400
commitabe4c34c86ccbe06ff4ecd50774c0205009d4620 (patch)
treec48e68ebf7db766a5fa4d0f9046945d957fcf65b /lib/dns.js
parente3ec2f7dabb08fbe66b1f1ec92ddabe71499e5b6 (diff)
downloadnodejs-abe4c34c86ccbe06ff4ecd50774c0205009d4620.tar.gz
nodejs-abe4c34c86ccbe06ff4ecd50774c0205009d4620.tar.bz2
nodejs-abe4c34c86ccbe06ff4ecd50774c0205009d4620.zip
dns: verify argument is valid function in resolve
Don't use argument as callback if it's not a valid callback function. Throw a valid exception instead explaining the issue. Adds to #7070 ("DNS — Throw meaningful error(s)").
Diffstat (limited to 'lib/dns.js')
-rw-r--r--lib/dns.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dns.js b/lib/dns.js
index cbba37258..d77159dad 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -185,9 +185,11 @@ exports.resolve = function(hostname, type_, callback_) {
if (util.isString(type_)) {
resolver = resolveMap[type_];
callback = callback_;
- } else {
+ } else if (util.isFunction(type_)) {
resolver = exports.resolve4;
callback = type_;
+ } else {
+ throw new Error('Type must be a string');
}
if (util.isFunction(resolver)) {