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

KindWhen
dns.nxdomainthe name does not exist
dns.servfailSERVFAIL, or any other code of the server
dns.refusedthe server refused the query
dns.truncatedthe answer has the TC flag
dns.timeoutno answer in time
dns.networkthe connection or the TLS handshake failed, ended before the whole answer, or an HTTPS server did not answer 200
dns.mismatchthe answer is not for the query
dns.malformedbytes that break RFC 1035, an HTTPS answer of another type, or an argument that does not fit
dns.cname_limitmore CNAMEs than max_cnames (8 by default), or a loop
dns.no_addresslookup 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), 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.