From 2c8d987241fea923f2cb7e35355385abf96af629 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 19 Apr 2018 07:55:09 -0700 Subject: [PATCH] Use Display formatting for InternalError Display implementation #188 --- CHANGES.md | 4 +++- src/error.rs | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1bc29ae1970..3745051dfa7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,13 @@ # Changes -## 0.5.4 (2018-04-xx) +## 0.5.4 (2018-04-19) * Add identity service middleware * Middleware response() is not invoked if there was an error in async handler #187 +* Use Display formatting for InternalError Display implementation #188 + ## 0.5.3 (2018-04-18) diff --git a/src/error.rs b/src/error.rs index da56c35c9ce..5f660c48f0f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -580,7 +580,7 @@ impl InternalError { impl Fail for InternalError where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { fn backtrace(&self) -> Option<&Backtrace> { Some(&self.backtrace) @@ -598,16 +598,16 @@ where impl fmt::Display for InternalError where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Display + 'static, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self.cause, f) + fmt::Display::fmt(&self.cause, f) } } impl ResponseError for InternalError where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { fn error_response(&self) -> HttpResponse { match self.status { @@ -625,7 +625,7 @@ where impl Responder for InternalError where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { type Item = HttpResponse; type Error = Error; @@ -640,7 +640,7 @@ where #[allow(non_snake_case)] pub fn ErrorBadRequest(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::BAD_REQUEST).into() } @@ -650,7 +650,7 @@ where #[allow(non_snake_case)] pub fn ErrorUnauthorized(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::UNAUTHORIZED).into() } @@ -660,7 +660,7 @@ where #[allow(non_snake_case)] pub fn ErrorForbidden(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::FORBIDDEN).into() } @@ -670,7 +670,7 @@ where #[allow(non_snake_case)] pub fn ErrorNotFound(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::NOT_FOUND).into() } @@ -680,7 +680,7 @@ where #[allow(non_snake_case)] pub fn ErrorMethodNotAllowed(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::METHOD_NOT_ALLOWED).into() } @@ -690,7 +690,7 @@ where #[allow(non_snake_case)] pub fn ErrorRequestTimeout(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::REQUEST_TIMEOUT).into() } @@ -700,7 +700,7 @@ where #[allow(non_snake_case)] pub fn ErrorConflict(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::CONFLICT).into() } @@ -710,7 +710,7 @@ where #[allow(non_snake_case)] pub fn ErrorGone(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::GONE).into() } @@ -720,7 +720,7 @@ where #[allow(non_snake_case)] pub fn ErrorPreconditionFailed(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::PRECONDITION_FAILED).into() } @@ -730,7 +730,7 @@ where #[allow(non_snake_case)] pub fn ErrorExpectationFailed(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::EXPECTATION_FAILED).into() } @@ -740,7 +740,7 @@ where #[allow(non_snake_case)] pub fn ErrorInternalServerError(err: T) -> Error where - T: Send + Sync + fmt::Debug + 'static, + T: Send + Sync + fmt::Debug + fmt::Display + 'static, { InternalError::new(err, StatusCode::INTERNAL_SERVER_ERROR).into() }