Skip to content

Commit 776c14c

Browse files
authored
fix: panic hook panic (#3182)
1 parent 135af21 commit 776c14c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cli/src/handler.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use eyre::EyreHandler;
22
use std::error::Error;
3+
use tracing::error;
34
use yansi::Paint;
45

56
/// A custom context type for Foundry specific error reporting via `eyre`
@@ -47,6 +48,7 @@ impl EyreHandler for Handler {
4748
/// verbose debug-centric handler is installed.
4849
///
4950
/// Panics are always caught by the more debug-centric handler.
51+
#[cfg_attr(windows, inline(never))]
5052
pub fn install() -> eyre::Result<()> {
5153
let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok();
5254

@@ -59,7 +61,14 @@ pub fn install() -> eyre::Result<()> {
5961
)
6062
.into_hooks();
6163
panic_hook.install();
62-
eyre::set_hook(Box::new(move |_| Box::new(Handler)))?;
64+
// see <https://github.com/foundry-rs/foundry/issues/3050>
65+
if cfg!(windows) {
66+
if let Err(err) = eyre::set_hook(Box::new(move |_| Box::new(Handler))) {
67+
error!(?err, "failed to install panic hook");
68+
}
69+
} else {
70+
eyre::set_hook(Box::new(move |_| Box::new(Handler)))?;
71+
}
6372
}
6473

6574
Ok(())

0 commit comments

Comments
 (0)