reth_dns_discovery/error.rs
1use crate::tree::TreeRootEntry;
2
3/// Alias for a parse result
4pub(crate) type ParseEntryResult<T> = Result<T, ParseDnsEntryError>;
5
6/// Alias for lookup results
7pub(crate) type LookupResult<T> = Result<T, LookupError>;
8
9/// Error while parsing a [`DnsEntry`](crate::tree::DnsEntry)
10#[derive(thiserror::Error, Debug)]
11pub enum ParseDnsEntryError {
12 /// Unknown entry error.
13 #[error("unknown entry: {0}")]
14 /// Indicates an unknown entry encountered during parsing.
15 UnknownEntry(String),
16 /// Field not found error.
17 #[error("field {0} not found")]
18 /// Indicates a field was not found during parsing.
19 FieldNotFound(&'static str),
20 /// Base64 decoding error.
21 #[error("base64 decoding failed: {0}")]
22 /// Indicates a failure during Base64 decoding.
23 Base64DecodeError(String),
24 /// Base32 decoding error.
25 #[error("base32 decoding failed: {0}")]
26 /// Indicates a failure during Base32 decoding.
27 Base32DecodeError(String),
28 /// RLP decoding error.
29 #[error("{0}")]
30 /// Indicates an error during RLP decoding.
31 RlpDecodeError(String),
32 /// Invalid child hash error in a branch.
33 #[error("invalid child hash in branch: {0}")]
34 /// Indicates an invalid child hash within a branch.
35 InvalidChildHash(String),
36 /// Other error.
37 #[error("{0}")]
38 /// Indicates other unspecified errors.
39 Other(String),
40}
41
42/// Errors that can happen during lookups
43#[derive(thiserror::Error, Debug)]
44pub(crate) enum LookupError {
45 /// Parse error.
46 #[error(transparent)]
47 /// Represents errors during parsing.
48 Parse(#[from] ParseDnsEntryError),
49 /// Invalid root error.
50 #[error("failed to verify root {0}")]
51 /// Indicates failure while verifying the root entry.
52 InvalidRoot(TreeRootEntry),
53 /// Request timed out error.
54 #[error("request timed out")]
55 /// Indicates a timeout occurred during the request.
56 RequestTimedOut,
57 /// Entry not found error.
58 #[error("entry not found")]
59 /// Indicates the requested entry was not found.
60 EntryNotFound,
61}