Per https://docs.rs/rootcause/latest/rootcause/handlers/index.html#1-formatting-function-selection :
The default behavior is to always use Display formatting, regardless of how the report itself is being formatted.
All built-in handlers (Error, Display, Debug, Any) use this default behavior, which means they use their display method even when the report is being debug-formatted with {:?}.
However, testing:
// [dependencies]
// rootcause = "0.12.1"
use rootcause::prelude::*;
fn main() -> Result<(), Report> {
std::fs::File::open("/nonexistent").attach("test")?;
Ok(())
}
yields (returning Err from main causes Error: {e:?} to be printed):
● Os { code: 2, kind: NotFound, message: "No such file or directory" }
├ src/main.rs:2
╰ "test"
And indeed, digging through the code, Report's Debug impl passes in FormattingFunction::Debug here, which gets threaded to DefaultReportFormatter::format_reports, which asks for the preferred formatting function for Debug here, and then, presumably ought to return a context using FormattingFunction::Display but doesn't, and thus eventually format_item uses Debug.
Per https://docs.rs/rootcause/latest/rootcause/handlers/index.html#1-formatting-function-selection :
However, testing:
yields (returning
ErrfrommaincausesError: {e:?}to be printed):And indeed, digging through the code,
Report'sDebugimpl passes inFormattingFunction::Debughere, which gets threaded to DefaultReportFormatter::format_reports, which asks for the preferred formatting function forDebughere, and then, presumably ought to return a context usingFormattingFunction::Displaybut doesn't, and thus eventuallyformat_itemusesDebug.