summaryrefslogtreecommitdiff
path: root/test/internet
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-10-15 13:01:23 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-10-16 21:56:16 +0200
commita2d1cbef6baabd767cef523078eb4e5921429d09 (patch)
tree149961f66f44d49b82207e7574982f51eca799d6 /test/internet
parentceb8740a636e59b1e34cb3db0c3c4c79bb501dfa (diff)
downloadnode-new-a2d1cbef6baabd767cef523078eb4e5921429d09.tar.gz
dns: set hostname property on error object
Make debugging and logging easier: when a DNS lookup for a hostname fails, set the hostname as a property on the error object. Fixes #5393.
Diffstat (limited to 'test/internet')
-rw-r--r--test/internet/test-dns.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js
index 5f360b4aee..cc69106c52 100644
--- a/test/internet/test-dns.js
+++ b/test/internet/test-dns.js
@@ -393,6 +393,45 @@ TEST(function test_lookup_localhost_ipv4(done) {
});
+TEST(function test_reverse_failure(done) {
+ var req = dns.reverse('0.0.0.0', function(err) {
+ assert(err instanceof Error);
+ assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
+ assert.strictEqual(err.hostname, '0.0.0.0');
+
+ done();
+ });
+
+ checkWrap(req);
+});
+
+
+TEST(function test_lookup_failure(done) {
+ var req = dns.lookup('nosuchhostimsure', function(err) {
+ assert(err instanceof Error);
+ assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
+ assert.strictEqual(err.hostname, 'nosuchhostimsure');
+
+ done();
+ });
+
+ checkWrap(req);
+});
+
+
+TEST(function test_resolve_failure(done) {
+ var req = dns.resolve4('nosuchhostimsure', function(err) {
+ assert(err instanceof Error);
+ assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
+ assert.strictEqual(err.hostname, 'nosuchhostimsure');
+
+ done();
+ });
+
+ checkWrap(req);
+});
+
+
/* Disabled because it appears to be not working on linux. */
/* TEST(function test_lookup_localhost_ipv6(done) {
var req = dns.lookup('localhost', 6, function(err, ip, family) {