From f7b2da2b5aa076855fa78ef37cc63377856f842b Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Fri, 19 Apr 2019 22:11:03 +0200 Subject: [PATCH] Add serde and internal error --- src/error.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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) + } +}