Skip to content

Commit

Permalink
Use Display formatting for InternalError Display implementation #188
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Apr 19, 2018
1 parent 813d1d6 commit 2c8d987
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
32 changes: 16 additions & 16 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ impl<T> InternalError<T> {

impl<T> Fail for InternalError<T>
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
fn backtrace(&self) -> Option<&Backtrace> {
Some(&self.backtrace)
Expand All @@ -598,16 +598,16 @@ where

impl<T> fmt::Display for InternalError<T>
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<T> ResponseError for InternalError<T>
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
fn error_response(&self) -> HttpResponse {
match self.status {
Expand All @@ -625,7 +625,7 @@ where

impl<T> Responder for InternalError<T>
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
type Item = HttpResponse;
type Error = Error;
Expand All @@ -640,7 +640,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorBadRequest<T>(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()
}
Expand All @@ -650,7 +650,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorUnauthorized<T>(err: T) -> Error
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
InternalError::new(err, StatusCode::UNAUTHORIZED).into()
}
Expand All @@ -660,7 +660,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorForbidden<T>(err: T) -> Error
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
InternalError::new(err, StatusCode::FORBIDDEN).into()
}
Expand All @@ -670,7 +670,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorNotFound<T>(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()
}
Expand All @@ -680,7 +680,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorMethodNotAllowed<T>(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()
}
Expand All @@ -690,7 +690,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorRequestTimeout<T>(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()
}
Expand All @@ -700,7 +700,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorConflict<T>(err: T) -> Error
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
InternalError::new(err, StatusCode::CONFLICT).into()
}
Expand All @@ -710,7 +710,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorGone<T>(err: T) -> Error
where
T: Send + Sync + fmt::Debug + 'static,
T: Send + Sync + fmt::Debug + fmt::Display + 'static,
{
InternalError::new(err, StatusCode::GONE).into()
}
Expand All @@ -720,7 +720,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorPreconditionFailed<T>(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()
}
Expand All @@ -730,7 +730,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorExpectationFailed<T>(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()
}
Expand All @@ -740,7 +740,7 @@ where
#[allow(non_snake_case)]
pub fn ErrorInternalServerError<T>(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()
}
Expand Down

0 comments on commit 2c8d987

Please sign in to comment.