diff --git a/cli/src/handler.rs b/cli/src/handler.rs index 8eb64bbc39a4..c803a646dfbb 100644 --- a/cli/src/handler.rs +++ b/cli/src/handler.rs @@ -1,5 +1,6 @@ use eyre::EyreHandler; use std::error::Error; +use tracing::error; use yansi::Paint; /// A custom context type for Foundry specific error reporting via `eyre` @@ -47,6 +48,7 @@ impl EyreHandler for Handler { /// verbose debug-centric handler is installed. /// /// Panics are always caught by the more debug-centric handler. +#[cfg_attr(windows, inline(never))] pub fn install() -> eyre::Result<()> { let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); @@ -59,7 +61,14 @@ pub fn install() -> eyre::Result<()> { ) .into_hooks(); panic_hook.install(); - eyre::set_hook(Box::new(move |_| Box::new(Handler)))?; + // see + if cfg!(windows) { + if let Err(err) = eyre::set_hook(Box::new(move |_| Box::new(Handler))) { + error!(?err, "failed to install panic hook"); + } + } else { + eyre::set_hook(Box::new(move |_| Box::new(Handler)))?; + } } Ok(())