diff --git a/lib/dns.js b/lib/dns.js index bd7789c6fa..fb7a8138c1 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -28,13 +28,14 @@ function errnoException(errorno, syscall) { // TODO make this more compatible with ErrnoException from src/node.cc // Once all of Node is using this function the ErrnoException from // src/node.cc should be removed. - var e = new Error(syscall + ' ' + errorno); // For backwards compatibility. libuv returns ENOENT on NXDOMAIN. if (errorno == 'ENOENT') { errorno = 'ENOTFOUND'; } + var e = new Error(syscall + ' ' + errorno); + e.errno = e.code = errorno; e.syscall = syscall; return e; diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index a079ec8d44..b781565c30 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -308,6 +308,7 @@ TEST(function test_lookup_failure(done) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, dns.NOTFOUND); assert.strictEqual(err.errno, 'ENOTFOUND'); + assert.ok(!/ENOENT/.test(err.message)); done(); });