Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop erroring on failing to install hooks #6148

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 5 additions & 9 deletions crates/cli/src/handler.rs
Original file line number Diff line number Diff line change
@@ -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`
Expand Down Expand Up @@ -53,21 +52,18 @@ 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(
"This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry",
)
.into_hooks();
panic_hook.install();
// see <https://github.com/foundry-rs/foundry/issues/3050>
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}");
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![warn(unused_crate_dependencies)]

#[macro_use]
extern crate tracing;

pub mod handler;
pub mod opts;
pub mod stdin;
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/opts/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::{
path::{Path, PathBuf},
str::FromStr,
};
use tracing::{instrument, trace};

pub mod multi_wallet;
pub use multi_wallet::*;
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/opts/wallet/multi_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use std::{
iter::repeat,
sync::Arc,
};
use tracing::trace;

macro_rules! get_wallets {
($id:ident, [ $($wallets:expr),+ ], $call:expr) => {
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/utils/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down