mirror of
https://github.com/haraldh/chainerror.git
synced 2025-06-05 07:44:36 +02:00
feat: removed feature display-cause
`display-cause` can be turned on with the `{:#}` format specifier
This commit is contained in:
parent
b2a62b2f55
commit
4eae3da3c1
4 changed files with 11 additions and 20 deletions
15
src/lib.rs
15
src/lib.rs
|
@ -92,11 +92,6 @@
|
|||
//!
|
||||
//! Debug information is worth it!
|
||||
//!
|
||||
//! ## Features
|
||||
//!
|
||||
//! `display-cause`
|
||||
//! : turn on printing a backtrace of the errors in `Display`
|
||||
//!
|
||||
//! # Tutorial
|
||||
//!
|
||||
//! Read the [Tutorial](https://haraldh.github.io/chainerror/tutorial1.html)
|
||||
|
@ -596,13 +591,12 @@ impl<T: 'static + Display + Debug> Display for ChainError<T> {
|
|||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
||||
write!(f, "{}", self.kind)?;
|
||||
|
||||
#[cfg(feature = "display-cause")]
|
||||
{
|
||||
if f.alternate() {
|
||||
if let Some(e) = self.source() {
|
||||
writeln!(f, "\nCaused by:")?;
|
||||
Display::fmt(&e, f)?;
|
||||
write!(f, "\nCaused by:\n {:#}", &e)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -633,8 +627,7 @@ impl<T: 'static + Display + Debug> Debug for ChainError<T> {
|
|||
}
|
||||
|
||||
if let Some(e) = self.source() {
|
||||
writeln!(f, "\nCaused by:")?;
|
||||
Debug::fmt(&e, f)?;
|
||||
write!(f, "\nCaused by:\n{:?}", &e)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue