From 71a37770610ccd2a49f9503c6aed61fa51e5ae0d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 27 Oct 2023 20:28:24 +0200 Subject: [PATCH] fix: stop erroring on failing to install hooks --- crates/cli/src/handler.rs | 14 +++++--------- crates/cli/src/lib.rs | 3 +++ crates/cli/src/opts/wallet/mod.rs | 1 - crates/cli/src/opts/wallet/multi_wallet.rs | 1 - crates/cli/src/utils/cmd.rs | 1 - 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/cli/src/handler.rs b/crates/cli/src/handler.rs index c1ee8fe29a95..a4154dc7cfe2 100644 --- a/crates/cli/src/handler.rs +++ b/crates/cli/src/handler.rs @@ -1,6 +1,5 @@ use eyre::{EyreHandler, Result}; use std::error::Error; -use tracing::error; use yansi::Paint; /// A custom context type for Foundry specific error reporting via `eyre` @@ -53,7 +52,9 @@ pub fn install() -> Result<()> { let debug_enabled = std::env::var("FOUNDRY_DEBUG").is_ok(); if debug_enabled { - color_eyre::install()?; + if let Err(e) = color_eyre::install() { + debug!("failed to install color eyre error hook: {e}"); + } } else { let (panic_hook, _) = color_eyre::config::HookBuilder::default() .panic_section( @@ -61,13 +62,8 @@ pub fn install() -> Result<()> { ) .into_hooks(); panic_hook.install(); - // 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)))?; + if let Err(e) = eyre::set_hook(Box::new(move |_| Box::new(Handler))) { + debug!("failed to install eyre error hook: {e}"); } } diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 39f4e95765dd..f0e90a96c58d 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -1,5 +1,8 @@ #![warn(unused_crate_dependencies)] +#[macro_use] +extern crate tracing; + pub mod handler; pub mod opts; pub mod stdin; diff --git a/crates/cli/src/opts/wallet/mod.rs b/crates/cli/src/opts/wallet/mod.rs index cd9fb0781113..437c5dc02ef3 100644 --- a/crates/cli/src/opts/wallet/mod.rs +++ b/crates/cli/src/opts/wallet/mod.rs @@ -27,7 +27,6 @@ use std::{ path::{Path, PathBuf}, str::FromStr, }; -use tracing::{instrument, trace}; pub mod multi_wallet; pub use multi_wallet::*; diff --git a/crates/cli/src/opts/wallet/multi_wallet.rs b/crates/cli/src/opts/wallet/multi_wallet.rs index 63fdb6110abd..bad22cb31c02 100644 --- a/crates/cli/src/opts/wallet/multi_wallet.rs +++ b/crates/cli/src/opts/wallet/multi_wallet.rs @@ -21,7 +21,6 @@ use std::{ iter::repeat, sync::Arc, }; -use tracing::trace; macro_rules! get_wallets { ($id:ident, [ $($wallets:expr),+ ], $call:expr) => { diff --git a/crates/cli/src/utils/cmd.rs b/crates/cli/src/utils/cmd.rs index f9b33604aa46..38ff31e4e164 100644 --- a/crates/cli/src/utils/cmd.rs +++ b/crates/cli/src/utils/cmd.rs @@ -22,7 +22,6 @@ use foundry_evm::{ }, }; use std::{fmt::Write, path::PathBuf, str::FromStr}; -use tracing::trace; use yansi::Paint; /// Given a `Project`'s output, removes the matching ABI, Bytecode and