dns: make error message match errno

This commit is contained in:
Dan Milon 2013-01-18 02:40:48 +02:00 committed by Ben Noordhuis
parent 31583be042
commit 7295bb9435
2 changed files with 3 additions and 1 deletions

View File

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

View File

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