Last active
November 18, 2022 14:40
-
-
Save ptrkrlsrd/5f35b60986ca837ab526fe99cbd3709c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
pub enum Err { | |
JSONError(serde_json::Error), | |
HTTPError(reqwest::Error), | |
} | |
macro_rules! convert_error { | |
($a:ty, $b:ident, $c:expr) => { | |
impl From<$a> for $b { | |
fn from(err: $a) -> Self { | |
$c(err) | |
} | |
} | |
} | |
} | |
convert_error!(serde_json::Error, Err, Err::JSONError); | |
convert_error!(reqwest::Error, Err, Err::HTTPError); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment