use std::fmt; use actix_codec::{Decoder, Encoder}; /// Framed service errors pub enum ServiceError { /// Inner service error Service(E), /// Encoder parse error Encoder(::Error), /// Decoder parse error Decoder(::Error), } impl From for ServiceError { fn from(err: E) -> Self { ServiceError::Service(err) } } impl fmt::Debug for ServiceError where E: fmt::Debug, ::Error: fmt::Debug, ::Error: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { ServiceError::Service(ref e) => write!(fmt, "ServiceError::Service({:?})", e), ServiceError::Encoder(ref e) => write!(fmt, "ServiceError::Encoder({:?})", e), ServiceError::Decoder(ref e) => write!(fmt, "ServiceError::Encoder({:?})", e), } } } impl fmt::Display for ServiceError where E: fmt::Display, ::Error: fmt::Debug, ::Error: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { ServiceError::Service(ref e) => write!(fmt, "{}", e), ServiceError::Encoder(ref e) => write!(fmt, "{:?}", e), ServiceError::Decoder(ref e) => write!(fmt, "{:?}", e), } } }