diff --git a/lib/dns.js b/lib/dns.js index 86b01ce713..ad919cc477 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -186,7 +186,7 @@ exports.resolve = function(domain, type_, callback_) { if (typeof resolver === 'function') { return resolver(domain, callback); } else { - throw new Error('Unknown type "' + type + '"'); + throw new Error('Unknown type "' + type_ + '"'); } }; diff --git a/test/simple/test-c-ares.js b/test/simple/test-c-ares.js index 7210dc2f14..3a3a9223d8 100644 --- a/test/simple/test-c-ares.js +++ b/test/simple/test-c-ares.js @@ -42,6 +42,11 @@ dns.lookup('::1', function(error, result, addressType) { assert.equal(6, addressType); }); +// Try calling resolve with an unsupported type. +assert.throws(function() { + dns.resolve('www.google.com', 'HI'); +}, /Unknown type/); + // Windows doesn't usually have an entry for localhost 127.0.0.1 in // C:\Windows\System32\drivers\etc\hosts // so we disable this test on Windows.