Skip to content

Commit 058e442

Browse files
author
splurf
committed
compat for parsing
1 parent 21e0000 commit 058e442

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/err.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ pub enum Error {
55
Cloudflare,
66
API,
77
Invalid,
8+
IO(std::io::Error),
9+
ParseInt(std::num::ParseIntError),
810
}
911

1012
impl From<reqwest::Error> for Error {
@@ -13,6 +15,18 @@ impl From<reqwest::Error> for Error {
1315
}
1416
}
1517

18+
impl From<std::io::Error> for Error {
19+
fn from(value: std::io::Error) -> Self {
20+
Self::IO(value)
21+
}
22+
}
23+
24+
impl From<std::num::ParseIntError> for Error {
25+
fn from(value: std::num::ParseIntError) -> Self {
26+
Self::ParseInt(value)
27+
}
28+
}
29+
1630
impl std::fmt::Debug for Error {
1731
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1832
std::fmt::Display::fmt(&self, f)
@@ -26,6 +40,10 @@ impl std::fmt::Display for Error {
2640
Self::Cloudflare => "Failed to properly retrieve dns record".to_string(),
2741
Self::API => "All public ip API failed".to_string(),
2842
Self::Invalid => "Invalid parsing for DNS record name".to_string(),
43+
Self::IO(e) => e.to_string(),
44+
Self::ParseInt(e) => e.to_string(),
2945
})
3046
}
3147
}
48+
49+
impl std::error::Error for Error {}

0 commit comments

Comments
 (0)