Reference

std/dns/error

std/dns/src/error.trb

DnsError: why a text is not a domain name, why bytes are not a DNS message, why a message cannot be written, and why a message is not the response to a query. Decoding bytes that came from the network answers one of these and never panics, whatever the bytes are.

type DnsError

type DnsError with Show, Error

Why a name, a message or a response was refused. Every case says where, so a log line can be checked by hand.

case InvalidName

case InvalidName(name: String, reason: String)

Text or labels that are not a domain name, and why: a label longer than 63 bytes, a character IDNA refuses.

case Truncated

case Truncated(offset: Int, part: String)

The message ends before part, which starts at byte offset, is complete.

case InvalidPointer

case InvalidPointer(offset: Int, target: Int)

A compression pointer at byte offset points at byte target, which is outside the message.

case PointerLoop

case PointerLoop(offset: Int)

A compression pointer at byte offset leads back to a pointer that was already followed.

case InvalidRecord

case InvalidRecord(recordType: RecordType, offset: Int, reason: String)

The data of a record at byte offset does not fit its type, and why.

case InvalidMessage

case InvalidMessage(offset: Int, reason: String)

Something else about the message at byte offset: a label type, a second OPT record, bytes after the end.

case Unencodable

case Unencodable(reason: String)

A message that the wire format cannot carry, and why: a text string of 300 bytes, a port of 70000.

case UnexpectedResponse

case UnexpectedResponse(reason: String)

A well-formed message that is not the response to the query it was read against, and why.

fn show

fn show(): String

One line that names what was refused and where.

extend DnsError with From<ReadError>

extend DnsError with From<ReadError>

A read of std/binary that failed on the bytes of a message: where they end is a truncated message, and anything else is a message that is not one. The codec names the part the bytes end in itself; this is what ? answers where no part is named.

fn from

static fn from(value: ReadError): DnsError