Possible discussion piece: I noticed that when using quick_run!, and it printed out the cause trace for an error that was returned, it can show duplicated messages depending on the implementation of the errors. This happens with reqwest, but see this small example:
enum Error {
Io(io::Error),
SomeCrateError,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Io(ref e) => fmt::Display::fmt(e),
// ...
}
}
}
impl ::std::error::Error for Error {
fn cause(&self) -> Option<&::std::error::Error> {
match *self {
Error::Io(ref e) -> Some(e),
_ => None,
}
}
}
Then, in some function somewhere:
fn do_a_thing() -> Result<(), Error> {
Err(io::Error::new(Other, "oh no"))?;
Ok(())
}
You’ll see this:
oh no
Caused by: oh no
This isn’t really error-chains fault, it’s just following the chain of causes. But it’s related, and also related to error design in general. If the crates Display were updated to not include the output from the wrapped io::Error, then it the display becomes much less useful when used without error-chain. For instance, if println!("{}", e) printed io error.