Add new error types
This commit is contained in:
parent
d6835b96de
commit
60cba9951f
16
src/error.rs
16
src/error.rs
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user