Implement client error

This commit is contained in:
Valentin Brandl 2019-04-21 20:44:47 +02:00
parent a30c4b1ac5
commit b12ba47be9
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -5,6 +5,7 @@ use std::fmt;
#[derive(Debug)]
pub(crate) enum Error {
Badge(String),
Client(reqwest::Error),
Git(git2::Error),
Internal,
Io(std::io::Error),
@ -13,9 +14,9 @@ pub(crate) enum Error {
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
// write!(fmt, "{}", P500)
match self {
Error::Badge(s) => write!(fmt, "Badge({})", s),
Error::Client(e) => write!(fmt, "Client({})", e),
Error::Git(e) => write!(fmt, "Git({})", e),
Error::Internal => write!(fmt, "Internal Error"),
Error::Io(e) => write!(fmt, "Io({})", e),
@ -63,3 +64,9 @@ impl From<serde_json::Error> for Error {
Error::Serial(err)
}
}
impl From<reqwest::Error> for Error {
fn from(err: reqwest::Error) -> Self {
Error::Client(err)
}
}