A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Migrate debugger to `wasmtime::error` (#12261)
Nick Fitzgerald0b980f4f7711
diff --git a/Cargo.lock b/Cargo.lockindex d6b94ba08c..a5ce307fe0 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4909,7 +4909,6 @@ dependencies = [name = "wasmtime-internal-debugger"version = "42.0.0"dependencies = [- "anyhow","env_logger 0.11.5","log","tokio",diff --git a/crates/debugger/Cargo.toml b/crates/debugger/Cargo.tomlindex a0a5a383f2..466b24c82b 100644--- a/crates/debugger/Cargo.toml+++ b/crates/debugger/Cargo.toml@@ -14,7 +14,6 @@ workspace = true[dependencies]wasmtime = { workspace = true, features = ["debug", "std", "async"] }tokio = { workspace = true, features = ["rt", "sync", "macros"] }-anyhow = { workspace = true }log = { workspace = true }[dev-dependencies]diff --git a/crates/debugger/src/lib.rs b/crates/debugger/src/lib.rsindex e575dfc6c9..fccf4b3faa 100644--- a/crates/debugger/src/lib.rs+++ b/crates/debugger/src/lib.rs@@ -218,7 +218,7 @@ impl<T: Send + 'static> Debugger<T> {}None => {// Premature exit due to closed channel. Just drop `inner`.- anyhow::bail!("Debugger channel dropped");+ wasmtime::bail!("Debugger channel dropped");}}@@ -259,7 +259,7 @@ impl<T: Send + 'static> Debugger<T> {self.in_tx.send(Command::Continue).await- .map_err(|_| anyhow::anyhow!("Failed to send over debug channel"))?;+ .map_err(|_| wasmtime::format_err!("Failed to send over debug channel"))?;log::trace!("sent Continue");// If that `send` was canceled, the command was not@@ -277,11 +277,10 @@ impl<T: Send + 'static> Debugger<T> {// the query was canceled, then transition back to// `Paused`.log::trace!("in Queried; receiving");- let response = self- .out_rx- .recv()- .await- .ok_or_else(|| anyhow::anyhow!("Premature close of debugger channel"))?;+ let response =+ self.out_rx.recv().await.ok_or_else(|| {+ wasmtime::format_err!("Premature close of debugger channel")+ })?;log::trace!("in Queried; received, dropping");assert!(matches!(response, Response::QueryResponse(_)));self.state = DebuggerState::Paused;@@ -291,7 +290,7 @@ impl<T: Send + 'static> Debugger<T> {self.in_tx.send(Command::Continue).await- .map_err(|_| anyhow::anyhow!("Failed to send over debug channel"))?;+ .map_err(|_| wasmtime::format_err!("Failed to send over debug channel"))?;self.state = DebuggerState::Running;}DebuggerState::Complete => {@@ -309,7 +308,7 @@ impl<T: Send + 'static> Debugger<T> {.out_rx.recv().await- .ok_or_else(|| anyhow::anyhow!("Premature close of debugger channel"))?;+ .ok_or_else(|| wasmtime::format_err!("Premature close of debugger channel"))?;match response {Response::Finished => {@@ -368,11 +367,10 @@ impl<T: Send + 'static> Debugger<T> {match self.state {DebuggerState::Queried => {// Earlier query canceled; drop its response first.- let response = self- .out_rx- .recv()- .await- .ok_or_else(|| anyhow::anyhow!("Premature close of debugger channel"))?;+ let response =+ self.out_rx.recv().await.ok_or_else(|| {+ wasmtime::format_err!("Premature close of debugger channel")+ })?;assert!(matches!(response, Response::QueryResponse(_)));self.state = DebuggerState::Paused;}@@ -392,16 +390,16 @@ impl<T: Send + 'static> Debugger<T> {self.in_tx.send(Command::Query(Box::new(|store| Box::new(f(store))))).await- .map_err(|_| anyhow::anyhow!("Premature close of debugger channel"))?;+ .map_err(|_| wasmtime::format_err!("Premature close of debugger channel"))?;self.state = DebuggerState::Queried;let response = self.out_rx.recv().await- .ok_or_else(|| anyhow::anyhow!("Premature close of debugger channel"))?;+ .ok_or_else(|| wasmtime::format_err!("Premature close of debugger channel"))?;let Response::QueryResponse(resp) = response else {- anyhow::bail!("Incorrect response from debugger task");+ wasmtime::bail!("Incorrect response from debugger task");};self.state = DebuggerState::Paused;@@ -463,7 +461,7 @@ mod test {#[tokio::test]#[cfg_attr(miri, ignore)]- async fn basic_debugger() -> anyhow::Result<()> {+ async fn basic_debugger() -> wasmtime::Result<()> {let _ = env_logger::try_init();let mut config = Config::new();