diff --git a/src/error.rs b/src/error.rs index df5bf64..b639c22 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,19 +2,23 @@ use actix_web::{HttpResponse, ResponseError}; #[derive(Debug)] pub(crate) enum Error { - Git(git2::Error), - Io(std::io::Error), Badge(String), + Git(git2::Error), + Internal, + Io(std::io::Error), ParseColor, + Serial(serde_json::Error), } impl std::fmt::Display for Error { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { match self { - Error::Git(e) => write!(fmt, "Git({})", e), - Error::Io(e) => write!(fmt, "Io({})", e), Error::Badge(s) => write!(fmt, "Badge({})", s), + Error::Git(e) => write!(fmt, "Git({})", e), + Error::Internal => write!(fmt, "Internal Error"), + Error::Io(e) => write!(fmt, "Io({})", e), Error::ParseColor => write!(fmt, "Parse error"), + Error::Serial(e) => write!(fmt, "Serial({})", e), } } } @@ -44,3 +48,9 @@ impl From for Error { Error::Io(err) } } + +impl From for Error { + fn from(err: serde_json::Error) -> Self { + Error::Serial(err) + } +}