Skip to content

Commit 680d7d4

Browse files
committed
Migrate wasmtime-cli to wasmtime::error
1 parent c89381f commit 680d7d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+237
-239
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ wasmtime-unwinder = { workspace = true }
6262
wasmtime-wizer = { workspace = true, optional = true, features = ['clap', 'wasmtime'] }
6363
clap = { workspace = true }
6464
clap_complete = { workspace = true, optional = true }
65-
anyhow = { workspace = true, features = ['std'] }
6665
target-lexicon = { workspace = true }
6766
listenfd = { version = "1.0.0", optional = true }
6867
wat = { workspace = true, optional = true }
@@ -139,9 +138,6 @@ windows-sys = { workspace = true, features = ["Win32_System_Memory"] }
139138
[target.'cfg(unix)'.dev-dependencies]
140139
rustix = { workspace = true, features = ["param"] }
141140

142-
[build-dependencies]
143-
anyhow = { workspace = true, features = ['std'] }
144-
145141
[profile.release.build-override]
146142
opt-level = 0
147143

examples/component/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use anyhow::Context;
21
use std::{fs, path::Path};
3-
42
use wasmtime::{
53
Config, Engine, Result, Store,
64
component::{Component, HasSelf, Linker, bindgen},
5+
error::Context as _,
76
};
87

98
// Generate bindings of the guest and host components.

examples/epochs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//! an example of setup for asynchronous usage, see
44
//! `tests/all/epoch_interruption.rs`
55
6-
use anyhow::Error;
76
use std::sync::Arc;
7+
use wasmtime::Error;
88
use wasmtime::{Config, Engine, Instance, Module, Store};
99

1010
fn main() -> Result<(), Error> {

examples/fast_instantiation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tuning Wasmtime for fast instantiation.
22
3-
use anyhow::anyhow;
3+
use wasmtime::format_err;
44
use wasmtime::{
55
Config, Engine, InstanceAllocationStrategy, Linker, Module, PoolingAllocationConfig, Result,
66
Store,
@@ -85,7 +85,7 @@ fn main() -> Result<()> {
8585

8686
// Wait for the threads to finish.
8787
for h in handles.into_iter() {
88-
h.join().map_err(|_| anyhow!("thread panicked!"))??;
88+
h.join().map_err(|_| format_err!("thread panicked!"))??;
8989
}
9090

9191
Ok(())

examples/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() -> Result<()> {
1818
// load_fn up our exports from the instance
1919
let memory = instance
2020
.get_memory(&mut store, "memory")
21-
.ok_or(anyhow::format_err!("failed to find `memory` export"))?;
21+
.ok_or(wasmtime::format_err!("failed to find `memory` export"))?;
2222
let size = instance.get_typed_func::<(), i32>(&mut store, "size")?;
2323
let load_fn = instance.get_typed_func::<i32, i32>(&mut store, "load")?;
2424
let store_fn = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store")?;

examples/mpk.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
//! $ sysctl vm.max_map_count=$LARGER_LIMIT
3232
//! ```
3333
34-
use anyhow::anyhow;
3534
use bytesize::ByteSize;
3635
use clap::Parser;
3736
use log::{info, warn};
3837
use std::str::FromStr;
38+
use wasmtime::format_err;
3939
use wasmtime::*;
4040

4141
fn main() -> Result<()> {
@@ -84,7 +84,7 @@ struct Args {
8484
/// Parse a human-readable byte size--e.g., "512 MiB"--into the correct number
8585
/// of bytes.
8686
fn parse_byte_size(value: &str) -> Result<u64> {
87-
let size = ByteSize::from_str(value).map_err(|e| anyhow!(e))?;
87+
let size = ByteSize::from_str(value).map_err(|e| format_err!(e))?;
8888
Ok(size.as_u64())
8989
}
9090

@@ -239,15 +239,15 @@ fn num_bytes_mapped() -> Result<usize> {
239239
let range = line
240240
.split_whitespace()
241241
.next()
242-
.ok_or(anyhow!("parse failure: expected whitespace"))?;
242+
.ok_or(format_err!("parse failure: expected whitespace"))?;
243243
let mut addresses = range.split("-");
244-
let start = addresses
245-
.next()
246-
.ok_or(anyhow!("parse failure: expected dash-separated address"))?;
244+
let start = addresses.next().ok_or(format_err!(
245+
"parse failure: expected dash-separated address"
246+
))?;
247247
let start = usize::from_str_radix(start, 16)?;
248-
let end = addresses
249-
.next()
250-
.ok_or(anyhow!("parse failure: expected dash-separated address"))?;
248+
let end = addresses.next().ok_or(format_err!(
249+
"parse failure: expected dash-separated address"
250+
))?;
251251
let end = usize::from_str_radix(end, 16)?;
252252

253253
total += end - start;
@@ -257,5 +257,5 @@ fn num_bytes_mapped() -> Result<usize> {
257257

258258
#[cfg(not(target_os = "linux"))]
259259
fn num_bytes_mapped() -> Result<usize> {
260-
anyhow::bail!("this example can only read virtual memory maps on Linux")
260+
wasmtime::bail!("this example can only read virtual memory maps on Linux")
261261
}

examples/multi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
// You can execute this example with `cargo run --example multi`
99

10-
use anyhow::Result;
10+
use wasmtime::Result;
1111

1212
fn main() -> Result<()> {
1313
use wasmtime::*;

examples/multimemory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ fn main() -> Result<()> {
2323

2424
let memory0 = instance
2525
.get_memory(&mut store, "memory0")
26-
.ok_or(anyhow::format_err!("failed to find `memory0` export"))?;
26+
.ok_or(wasmtime::format_err!("failed to find `memory0` export"))?;
2727
let size0 = instance.get_typed_func::<(), i32>(&mut store, "size0")?;
2828
let load0 = instance.get_typed_func::<i32, i32>(&mut store, "load0")?;
2929
let store0 = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store0")?;
3030

3131
let memory1 = instance
3232
.get_memory(&mut store, "memory1")
33-
.ok_or(anyhow::format_err!("failed to find `memory1` export"))?;
33+
.ok_or(wasmtime::format_err!("failed to find `memory1` export"))?;
3434
let size1 = instance.get_typed_func::<(), i32>(&mut store, "size1")?;
3535
let load1 = instance.get_typed_func::<i32, i32>(&mut store, "load1")?;
3636
let store1 = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store1")?;

examples/tokio/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use anyhow::Error;
21
use std::sync::Arc;
32
use tokio::time::Duration;
3+
use wasmtime::Error;
44
use wasmtime::{Config, Engine, Linker, Module, Store};
55
use wasmtime_wasi::{WasiCtx, p1::WasiP1Ctx};
66

0 commit comments

Comments
 (0)