Browse Source

dns: make error message match errno

v0.8.18-release
Dan Milon 12 years ago
committed by Ben Noordhuis
parent
commit
7295bb9435
  1. 3
      lib/dns.js
  2. 1
      test/internet/test-dns.js

3
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;

1
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();
});

Loading…
Cancel
Save