Skip to content

Commit

Permalink
dns: make error message match errno
Browse files Browse the repository at this point in the history
  • Loading branch information
danmilon authored and bnoordhuis committed Jan 18, 2013
1 parent 31583be commit 7295bb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/internet/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit 7295bb9

Please sign in to comment.