# Errors

An `error` of this package has a kind, tested with `e.is_a?("dns.nxdomain")`. The constants are `DNS.NXDOMAIN` and the like.

| Kind | When |
|---|---|
| `dns.nxdomain` | the name does not exist |
| `dns.servfail` | SERVFAIL, or any other code of the server |
| `dns.refused` | the server refused the query |
| `dns.truncated` | the answer has the TC flag |
| `dns.timeout` | no answer in time |
| `dns.network` | the connection or the TLS handshake failed, ended before the whole answer, or an HTTPS server did not answer 200 |
| `dns.mismatch` | the answer is not for the query |
| `dns.malformed` | bytes that break RFC 1035, an HTTPS answer of another type, or an argument that does not fit |
| `dns.cname_limit` | more CNAMEs than `max_cnames` (8 by default), or a loop |
| `dns.no_address` | `lookup` of a name that has no address |

A query that ends in `dns.servfail`, `dns.refused`, `dns.truncated`, `dns.timeout`, `dns.network`, `dns.mismatch` or `dns.malformed` (from an answer) has been tried on every server first (see [nameservers](https://www.agentica-lang.com/packages/dns/nameservers/index.md)), and the kind is the one of the last server. `dns.nxdomain` ends the search at the first server that says it. `dns.cname_limit` and `dns.no_address` come from the answers that a server gave, and an argument that does not fit is a `dns.malformed` before any server is asked.
