Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion foundations/src/panic/hook.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Panic hook implementation for tracking panics.

use std::io::Write;
use std::panic::{self, PanicHookInfo};

/// Install the panic hook.
Expand Down Expand Up @@ -57,7 +58,10 @@ fn log_panic(panic_info: &PanicHookInfo<'_>) {
"payload": payload,
"location": location_str
});
eprintln!("{}", json_output);
// Grab stderr ourselves and ignore any write error to avoid double-panicking
// (e.g. if stderr is closed) within the panic hook.
let mut stderr = std::io::stderr().lock();
let _ = writeln!(stderr, "{}", json_output);
}

fn panic_payload_as_str<'a>(panic_info: &'a PanicHookInfo<'_>) -> &'a str {
Expand Down
Loading