Skip to content

Commit

Permalink
c-api: Avoid losing error context with instance traps
Browse files Browse the repository at this point in the history
This commit was a mistake from bytecodealliance#5149
  • Loading branch information
alexcrichton committed Nov 8, 2022
1 parent d4f3851 commit c61b1ce
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/c-api/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ pub(crate) fn handle_instantiate(
*instance_ptr = i;
None
}
Err(e) => match e.downcast::<Trap>() {
Ok(trap) => {
*trap_ptr = Box::into_raw(Box::new(wasm_trap_t::new(trap.into())));
Err(e) => {
if e.is::<Trap>() {
*trap_ptr = Box::into_raw(Box::new(wasm_trap_t::new(e)));
None
} else {
Some(Box::new(e.into()))
}
Err(e) => Some(Box::new(e.into())),
},
}
}
}

Expand Down

0 comments on commit c61b1ce

Please sign in to comment.