Skip to content

Commit 6d33c15

Browse files
committed
Restore 'Stack backtrace:' above the backtrace
The header originally printed by the backtrace crate was removed in rust-lang/backtrace-rs#286 to give downstream formatting code a chance to incorporate whatever kind of header they want. So we do that.
1 parent 2aa0cc1 commit 6d33c15

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/fmt.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ impl ErrorImpl<()> {
4545
let backtrace = self.backtrace();
4646
if let BacktraceStatus::Captured = backtrace.status() {
4747
let mut backtrace = backtrace.to_string();
48+
write!(f, "\n\n")?;
4849
if backtrace.starts_with("stack backtrace:") {
4950
// Capitalize to match "Caused by:"
5051
backtrace.replace_range(0..1, "S");
52+
} else {
53+
// "stack backtrace:" prefix was removed in
54+
// https://github.com/rust-lang/backtrace-rs/pull/286
55+
writeln!(f, "Stack backtrace:")?;
5156
}
5257
backtrace.truncate(backtrace.trim_end().len());
53-
write!(f, "\n\n{}", backtrace)?;
58+
write!(f, "{}", backtrace)?;
5459
}
5560
}
5661

0 commit comments

Comments
 (0)