1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#[derive(Debug)] pub enum Error { JSON(serde_json::error::Error), Utf8(std::str::Utf8Error), IOError(std::io::Error), InvalidOption(String), HWIError(String), } macro_rules! impl_error { ( $from:ty, $to:ident ) => { impl std::convert::From<$from> for Error { fn from(err: $from) -> Self { Error::$to(err) } } }; } impl_error!(serde_json::Error, JSON); impl_error!(std::str::Utf8Error, Utf8); impl_error!(std::io::Error, IOError);