c-api: Avoid losing error context with instance traps (#5223)

This commit was a mistake from #5149
This commit is contained in:
Alex Crichton
2022-11-08 11:43:20 -06:00
committed by GitHub
parent 3e5938e65a
commit 7b5fd84082

View File

@@ -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())),
},
}
}
}