Skip to content

Commit

Permalink
Handle panic!("...") in catch_unwind handling
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Dec 11, 2024
1 parent 8e40161 commit 7967f33
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ impl<'a> TestRunner<'a> {
let time_before_test = std::time::Instant::now();
let (status, output) = match catch_unwind(test.runner) {
Ok((status, output)) => (status, output),
Err(_) => (
Err(err) => (
TestStatus::Fail {
message: "An unexpected error happened".to_string(),
message:
// It seems `panic!("...")` makes the error be `&str`, so we handle this common case
if let Some(message) = err.downcast_ref::<&str>() {
message.to_string()
} else {
"An unexpected error happened".to_string()
},
error_diagnostic: None,
},
String::new(),
Expand Down

0 comments on commit 7967f33

Please sign in to comment.