Add new error types

This commit is contained in:
Valentin Brandl 2019-05-14 01:11:54 +02:00
parent d6835b96de
commit 60cba9951f
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -11,6 +11,8 @@ pub(crate) enum Error {
Git(git2::Error),
Internal,
Io(std::io::Error),
Log(log::SetLoggerError),
LogBuilder(log4rs::config::Errors),
Serial(serde_json::Error),
}
@ -22,6 +24,8 @@ impl fmt::Display for Error {
Error::Git(e) => write!(fmt, "Git({})", e),
Error::Internal => write!(fmt, "Internal Error"),
Error::Io(e) => write!(fmt, "Io({})", e),
Error::Log(e) => write!(fmt, "Log({})", e),
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
Error::Serial(e) => write!(fmt, "Serial({})", e),
}
}
@ -55,6 +59,12 @@ impl From<git2::Error> for Error {
}
}
impl From<log::SetLoggerError> for Error {
fn from(err: log::SetLoggerError) -> Self {
Error::Log(err)
}
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
Error::Io(err)
@ -72,3 +82,9 @@ impl From<reqwest::Error> for Error {
Error::Client(err)
}
}
impl From<log4rs::config::Errors> for Error {
fn from(err: log4rs::config::Errors) -> Self {
Error::LogBuilder(err)
}
}