=== Error handling

As you saw in previous sections the DnsClient allows you to pass in a Handler which will be notified with an
AsyncResult once the query was complete.

In case of an error it will be notified with a DnsException which will
hole a `link:../../vertx-core/enums.html#DnsResponseCode[DnsResponseCode]` that indicate why the resolution failed. This DnsResponseCode
can be used to inspect the cause in more detail.

Possible DnsResponseCodes are:

- `link:todo[NOERROR]` No record was found for a given query
- `link:todo[FORMERROR]` Format error
- `link:todo[SERVFAIL]` Server failure
- `link:todo[NXDOMAIN]` Name error
- `link:todo[NOTIMPL]` Not implemented by DNS Server
- `link:todo[REFUSED]` DNS Server refused the query
- `link:todo[YXDOMAIN]` Domain name should not exist
- `link:todo[YXRRSET]` Resource record should not exist
- `link:todo[NXRRSET]` RRSET does not exist
- `link:todo[NOTZONE]` Name not in zone
- `link:todo[BADVERS]` Bad extension mechanism for version
- `link:todo[BADSIG]` Bad signature
- `link:todo[BADKEY]` Bad key
- `link:todo[BADTIME]` Bad timestamp

All of those errors are "generated" by the DNS Server itself.

You can obtain the `DnsResponseCode` from the `DnsException` like:

[source,groovy]
----
def client = vertx.createDnsClient(53, "8.8.8.8");
client.lookup("missing.vertx.io", { ar ->
 if (ar.succeeded()) {
   def record = ar.result();
   println "record: " + record;
 } else {
   def cause = ar.cause();
   if (cause instanceof DnsException) {
   def code = cause.code();
   println "Code : " + code
   // ...
   } else {
     println("Failed to resolve entry" + ar.cause());
   }
 }
})
----