1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use std::string::FromUtf8Error; use rustc_serialize::base64::FromBase64Error; use rustc_serialize::json; #[derive(Debug)] pub enum Error { Format, Base64, Decode, Encode, Json, Parse, Utf8, } macro_rules! error_wrap { ($f: ty, $e: expr) => { impl From<$f> for Error { fn from(_: $f) -> Error { $e } } } } error_wrap!(FromBase64Error, Error::Base64); error_wrap!(json::DecoderError, Error::Decode); error_wrap!(json::EncoderError, Error::Encode); error_wrap!(json::ErrorCode, Error::Json); error_wrap!(json::ParserError, Error::Parse); error_wrap!(FromUtf8Error, Error::Utf8);