Add parse error

This commit is contained in:
Valentin Brandl 2019-07-07 13:29:26 +02:00
parent ed1cafafd0
commit 00b4e60341
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -16,6 +16,7 @@ pub(crate) enum Error {
Io(std::io::Error),
Log(log::SetLoggerError),
LogBuilder(log4rs::config::Errors),
Parse(std::num::ParseIntError),
Serial(serde_json::Error),
}
@ -29,6 +30,7 @@ impl fmt::Display for Error {
Error::Io(e) => write!(fmt, "Io({})", e),
Error::Log(e) => write!(fmt, "Log({})", e),
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
Error::Parse(e) => write!(fmt, "Parse({})", e),
Error::Serial(e) => write!(fmt, "Serial({})", e),
}
}
@ -91,3 +93,9 @@ impl From<log4rs::config::Errors> for Error {
Error::LogBuilder(err)
}
}
impl From<std::num::ParseIntError> for Error {
fn from(err: std::num::ParseIntError) -> Self {
Error::Parse(err)
}
}