### 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 `DnsResponseCode` that indicate why the resolution failed. This DnsResponseCode can be used to inspect the cause in more detail.

Possible DnsResponseCodes are:

- `NOERROR` No record was found for a given query

- `FORMERROR` Format error

- `SERVFAIL` Server failure

- `NXDOMAIN` Name error

- `NOTIMPL` Not implemented by DNS Server

- `REFUSED` DNS Server refused the query

- `YXDOMAIN` Domain name should not exist

- `YXRRSET` Resource record should not exist

- `NXRRSET` RRSET does not exist

- `NOTZONE` Name not in zone

- `BADVERS` Bad extension mechanism for version

- `BADSIG` Bad signature

- `BADKEY` Bad key

- `BADTIME` Bad timestamp

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

You can obtain the DnsResponseCode from the DnsException like:

    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.lookup("nonexisting.vert.xio", ar -> {
      if (ar.succeeded()) {
        String record = ar.result();
        System.out.println(record);
      } else {
        Throwable cause = ar.cause();
        if (cause instanceof DnsException) {
          DnsException exception = (DnsException) cause;
          DnsResponseCode code = exception.code();
          // ...
        } else {
          System.out.println("Failed to resolve entry" + ar.cause());
        }
      }
    });