diff options
author | Antoine Büsch <antoine.busch@gmail.com> | 2018-09-24 11:11:44 +1000 |
---|---|---|
committer | Antoine Büsch <antoine.busch@gmail.com> | 2018-10-01 11:54:36 +1000 |
commit | 99fc8b45d7ce71377fb992d2ec215eb19bc77ab1 (patch) | |
tree | c5ee851ec5e9fbeff158817073e36c696421a416 /src/errors.rs | |
parent | 7fb4ea5098fe7a47903d3ca7fab80561a69ddc32 (diff) |
Migrate to serde_json
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/errors.rs b/src/errors.rs index d4905a1..44be52a 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -2,37 +2,23 @@ use http; use hyper::{self, StatusCode}; -use rustc_serialize::json::{DecoderError, EncoderError, ParserError}; +use serde_json::Error as SerdeError; use std::error::Error as ErrorTrait; use std::fmt; use std::io::Error as IoError; #[derive(Debug)] pub enum Error { - Decoding(DecoderError), - Encoding(EncoderError), - Parse(ParserError), + SerdeJsonError(SerdeError), Hyper(hyper::Error), Http(http::Error), IO(IoError), Fault { code: StatusCode, message: String }, } -impl From<ParserError> for Error { - fn from(error: ParserError) -> Error { - Error::Parse(error) - } -} - -impl From<DecoderError> for Error { - fn from(error: DecoderError) -> Error { - Error::Decoding(error) - } -} - -impl From<EncoderError> for Error { - fn from(error: EncoderError) -> Error { - Error::Encoding(error) +impl From<SerdeError> for Error { + fn from(error: SerdeError) -> Error { + Error::SerdeJsonError(error) } } @@ -58,9 +44,7 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Docker Error: ")?; match self { - &Error::Decoding(ref err) => return err.fmt(f), - &Error::Encoding(ref err) => return err.fmt(f), - &Error::Parse(ref err) => return err.fmt(f), + &Error::SerdeJsonError(ref err) => return err.fmt(f), &Error::Http(ref err) => return err.fmt(f), &Error::Hyper(ref err) => return err.fmt(f), &Error::IO(ref err) => return err.fmt(f), @@ -76,9 +60,7 @@ impl ErrorTrait for Error { fn cause(&self) -> Option<&ErrorTrait> { match self { - &Error::Decoding(ref err) => Some(err), - &Error::Encoding(ref err) => Some(err), - &Error::Parse(ref err) => Some(err), + &Error::SerdeJsonError(ref err) => Some(err), &Error::Http(ref err) => Some(err), &Error::IO(ref err) => Some(err), _ => None, |