()
| 1621 | #[tokio::test] |
| 1622 | #[cfg_attr(miri, ignore)] |
| 1623 | async fn take_exception_in_debug_handler() -> Result<()> { |
| 1624 | let mut config = Config::new(); |
| 1625 | config.wasm_exceptions(true); |
| 1626 | config.guest_debug(true); |
| 1627 | let engine = Engine::new(&config)?; |
| 1628 | let mut store = Store::new(&engine, ()); |
| 1629 | store.set_debug_handler(TakeExceptionHandler); |
| 1630 | |
| 1631 | let module = Module::new( |
| 1632 | &engine, |
| 1633 | r#" |
| 1634 | (module |
| 1635 | (tag $t) |
| 1636 | (func (export "run") |
| 1637 | (block $h (try_table (catch_all $h) (throw $t))) |
| 1638 | ) |
| 1639 | ) |
| 1640 | "#, |
| 1641 | )?; |
| 1642 | let instance = Instance::new_async(&mut store, &module, &[]).await?; |
| 1643 | let run = instance.get_typed_func::<(), ()>(&mut store, "run")?; |
| 1644 | let err = run.call_async(&mut store, ()).await.unwrap_err(); |
| 1645 | assert!(err.is::<wasmtime::ThrownException>()); |
| 1646 | return Ok(()); |
| 1647 | |
| 1648 | #[derive(Clone)] |
| 1649 | struct TakeExceptionHandler; |
| 1650 | |
| 1651 | impl DebugHandler for TakeExceptionHandler { |
| 1652 | type Data = (); |
| 1653 | |
| 1654 | fn handle( |
| 1655 | &self, |
| 1656 | mut store: StoreContextMut<'_, ()>, |
| 1657 | event: DebugEvent<'_>, |
| 1658 | ) -> impl Future<Output = ()> + Send { |
| 1659 | let did_take = matches!(event, DebugEvent::Exception(_)); |
| 1660 | // Eat the pending exception that compute_handler put back. |
| 1661 | if did_take { |
| 1662 | let _ = store.take_pending_exception(); |
| 1663 | } |
| 1664 | async move {} |
| 1665 | } |
| 1666 | } |
| 1667 | } |
nothing calls this directly
no test coverage detected