From 60cba9951ffdc801e01170804f6b310480e80415 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 14 May 2019 01:11:54 +0200 Subject: [PATCH] Add new error types --- src/error.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/error.rs b/src/error.rs index 55f27b2..3e64372 100644 --- a/src/error.rs +++ b/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 for Error { } } +impl From for Error { + fn from(err: log::SetLoggerError) -> Self { + Error::Log(err) + } +} + impl From for Error { fn from(err: std::io::Error) -> Self { Error::Io(err) @@ -72,3 +82,9 @@ impl From for Error { Error::Client(err) } } + +impl From for Error { + fn from(err: log4rs::config::Errors) -> Self { + Error::LogBuilder(err) + } +}