Skip to content

Commit 1ea6eda

Browse files
committed
fix: add error impl for DnsDecodeError
1 parent 0990d54 commit 1ea6eda

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/net.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,17 @@ pub fn dnswire_decode(wire_format_bytes: &[u8]) -> Result<String, DnsDecodeError
155155
}
156156
}
157157

158-
#[derive(Clone, Debug)]
158+
#[derive(Clone, Debug, thiserror::Error)]
159159
pub enum DnsDecodeError {
160160
Utf8Error(std::string::FromUtf8Error),
161161
FormatError,
162162
}
163+
164+
impl std::fmt::Display for DnsDecodeError {
165+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
166+
match self {
167+
DnsDecodeError::Utf8Error(e) => write!(f, "UTF-8 error: {}", e),
168+
DnsDecodeError::FormatError => write!(f, "Format error"),
169+
}
170+
}
171+
}

0 commit comments

Comments
 (0)