Skip to content
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
12 changes: 11 additions & 1 deletion crates/evm/evm/src/executors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ pub enum EvmError {
Skip(SkipReason),
/// Any other error.
#[error(transparent)]
Eyre(#[from] eyre::Error),
Eyre(eyre::Error),
}

impl From<ExecutionErr> for EvmError {
Expand All @@ -678,6 +678,16 @@ impl From<alloy_sol_types::Error> for EvmError {
}
}

impl From<eyre::Error> for EvmError {
fn from(err: eyre::Report) -> Self {
let mut chained_cause = String::new();
for cause in err.chain() {
chained_cause.push_str(format!("{cause}; ").as_str());
}
Self::Eyre(eyre::format_err!("{chained_cause}"))
}
}

/// The result of a deployment.
#[derive(Debug)]
pub struct DeployResult {
Expand Down
24 changes: 24 additions & 0 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,3 +2210,27 @@ Simulated On-chain Traces:
...
"#]]);
});

// Tests that chained errors are properly displayed.
// <https://github.com/foundry-rs/foundry/issues/9161>
forgetest_init!(should_display_evm_chained_error, |prj, cmd| {
let script = prj
.add_source(
"Foo",
r#"
import "forge-std/Script.sol";

contract ContractScript is Script {
function run() public {
}
}
"#,
)
.unwrap();
cmd.arg("script").arg(script).args(["--fork-url", "https://public-node.testnet.rsk.co"]).assert_failure().stderr_eq(str![[r#"
Error:
Failed to deploy script:
backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set;

"#]]);
});
Loading