File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -663,7 +663,7 @@ pub enum EvmError {
663
663
Skip ( SkipReason ) ,
664
664
/// Any other error.
665
665
#[ error( transparent) ]
666
- Eyre ( # [ from ] eyre:: Error ) ,
666
+ Eyre ( eyre:: Error ) ,
667
667
}
668
668
669
669
impl From < ExecutionErr > for EvmError {
@@ -678,6 +678,16 @@ impl From<alloy_sol_types::Error> for EvmError {
678
678
}
679
679
}
680
680
681
+ impl From < eyre:: Error > for EvmError {
682
+ fn from ( err : eyre:: Report ) -> Self {
683
+ let mut chained_cause = String :: new ( ) ;
684
+ for cause in err. chain ( ) {
685
+ chained_cause. push_str ( format ! ( "{cause}; " ) . as_str ( ) ) ;
686
+ }
687
+ Self :: Eyre ( eyre:: format_err!( "{chained_cause}" ) )
688
+ }
689
+ }
690
+
681
691
/// The result of a deployment.
682
692
#[ derive( Debug ) ]
683
693
pub struct DeployResult {
Original file line number Diff line number Diff line change @@ -2210,3 +2210,27 @@ Simulated On-chain Traces:
2210
2210
...
2211
2211
"# ] ] ) ;
2212
2212
} ) ;
2213
+
2214
+ // Tests that chained errors are properly displayed.
2215
+ // <https://github.com/foundry-rs/foundry/issues/9161>
2216
+ forgetest_init ! ( should_display_evm_chained_error, |prj, cmd| {
2217
+ let script = prj
2218
+ . add_source(
2219
+ "Foo" ,
2220
+ r#"
2221
+ import "forge-std/Script.sol";
2222
+
2223
+ contract ContractScript is Script {
2224
+ function run() public {
2225
+ }
2226
+ }
2227
+ "# ,
2228
+ )
2229
+ . unwrap( ) ;
2230
+ cmd. arg( "script" ) . arg( script) . args( [ "--fork-url" , "https://public-node.testnet.rsk.co" ] ) . assert_failure( ) . stderr_eq( str ![ [ r#"
2231
+ Error:
2232
+ Failed to deploy script:
2233
+ backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set;
2234
+
2235
+ "# ] ] ) ;
2236
+ } ) ;
You can’t perform that action at this time.
0 commit comments