Skip to content

Commit a5a451e

Browse files
committed
Remove duplicate error "caused by" logging
The `impl<E: AppError> fmt::Display for ChainedError<E>` is sufficient.
1 parent 9d8a6bb commit a5a451e

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

src/util/errors.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ struct Bad {
4242
// AppError trait
4343

4444
pub trait AppError: Send + fmt::Display + fmt::Debug + 'static {
45-
fn cause(&self) -> Option<&(dyn AppError)> {
46-
None
47-
}
48-
4945
/// Generate an HTTP response for the error
5046
///
5147
/// If none is returned, the error will bubble up the middleware stack
@@ -80,9 +76,6 @@ impl dyn AppError {
8076
}
8177

8278
impl AppError for Box<dyn AppError> {
83-
fn cause(&self) -> Option<&dyn AppError> {
84-
(**self).cause()
85-
}
8679
fn response(&self) -> Option<Response> {
8780
(**self).response()
8881
}
@@ -148,9 +141,6 @@ impl<T> ChainError<T> for Option<T> {
148141
}
149142

150143
impl<E: AppError> AppError for ChainedError<E> {
151-
fn cause(&self) -> Option<&dyn AppError> {
152-
Some(&*self.cause)
153-
}
154144
fn response(&self) -> Option<Response> {
155145
self.error.response()
156146
}
@@ -284,15 +274,7 @@ impl Error for AppErrToStdErr {}
284274

285275
impl fmt::Display for AppErrToStdErr {
286276
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
287-
write!(f, "{}", self.0)?;
288-
289-
let mut err = &*self.0;
290-
while let Some(cause) = err.cause() {
291-
err = cause;
292-
write!(f, "\nCaused by: {}", err)?;
293-
}
294-
295-
Ok(())
277+
self.0.fmt(f)
296278
}
297279
}
298280

0 commit comments

Comments
 (0)