From 7295bb9435c10fe569d36e64d50769fed4b5d7e3 Mon Sep 17 00:00:00 2001 From: Dan Milon Date: Fri, 18 Jan 2013 02:40:48 +0200 Subject: [PATCH] dns: make error message match errno --- lib/dns.js | 3 ++- test/internet/test-dns.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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(); });