//
// async method passing errors via
// the standard convention of callback(err)
//
> dns.reverse('4.4.4.4', console.log)
{ oncomplete: [Function: onanswer] }
> { [Error: getHostByAddr ENOTFOUND]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getHostByAddr' }
//
// but wait! it also throws exceptions!
//
> dns.reverse('boobs.com', console.log)
Error: getHostByAddr ENOTIMP
at errnoException (dns.js:37:11)
at Object.query [as reverse] (dns.js:156:13)
at repl:1:6
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
//
// so you have to write code like this???
// which leads duplicate error handling plus
// awesome stacktraces, btw, if your callback happens to throw an exception
//
> try {
dns.reverse('asdfasdf', console.log);
} catch (err) { console.error("SERIOUSLY NODE???", err); }
SERIOUSLY NODE??? { [Error: getHostByAddr ENOTIMP] code: 'ENOTIMP', errno: 'ENOTIMP', syscall: 'getHostByAddr' }
Yes there is an open issue: nodejs/node-v0.x-archive#6505