Skip to content

Commit 662c9f9

Browse files
authored
wasmtime-unwinder: Use wasmtime_environ::error instead of anyhow (#12208)
1 parent f42df64 commit 662c9f9

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

Cargo.lock

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

crates/unwinder/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cranelift-codegen = { workspace = true, optional = true }
2020
log = { workspace = true }
2121
cfg-if = { workspace = true }
2222
object = { workspace = true }
23-
anyhow = { workspace = true }
23+
wasmtime-environ = { workspace = true }
2424

2525
[features]
2626
default = []

crates/unwinder/src/exception_table.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl ExceptionTableBuilder {
127127
&mut self,
128128
start_offset: CodeOffset,
129129
call_sites: impl Iterator<Item = FinalizedMachCallSite<'a>>,
130-
) -> anyhow::Result<()> {
130+
) -> wasmtime_environ::error::Result<()> {
131131
// Ensure that we see functions in offset order.
132132
assert!(start_offset >= self.last_start_offset);
133133
self.last_start_offset = start_offset;
@@ -252,36 +252,37 @@ pub struct ExceptionHandler {
252252
impl<'a> ExceptionTable<'a> {
253253
/// Parse exception tables from a byte-slice as produced by
254254
/// [`ExceptionTableBuilder::serialize`].
255-
pub fn parse(data: &'a [u8]) -> anyhow::Result<ExceptionTable<'a>> {
255+
pub fn parse(data: &'a [u8]) -> wasmtime_environ::error::Result<ExceptionTable<'a>> {
256256
let mut data = Bytes(data);
257-
let callsite_count = data
258-
.read::<U32Bytes<LittleEndian>>()
259-
.map_err(|_| anyhow::anyhow!("Unable to read callsite count prefix"))?;
257+
let callsite_count = data.read::<U32Bytes<LittleEndian>>().map_err(|_| {
258+
wasmtime_environ::error::anyhow!("Unable to read callsite count prefix")
259+
})?;
260260
let callsite_count = usize::try_from(callsite_count.get(LittleEndian))?;
261261
let handler_count = data
262262
.read::<U32Bytes<LittleEndian>>()
263-
.map_err(|_| anyhow::anyhow!("Unable to read handler count prefix"))?;
263+
.map_err(|_| wasmtime_environ::error::anyhow!("Unable to read handler count prefix"))?;
264264
let handler_count = usize::try_from(handler_count.get(LittleEndian))?;
265265
let (callsites, data) =
266266
object::slice_from_bytes::<U32Bytes<LittleEndian>>(data.0, callsite_count)
267-
.map_err(|_| anyhow::anyhow!("Unable to read callsites slice"))?;
267+
.map_err(|_| wasmtime_environ::error::anyhow!("Unable to read callsites slice"))?;
268268
let (frame_offsets, data) =
269-
object::slice_from_bytes::<U32Bytes<LittleEndian>>(data, callsite_count)
270-
.map_err(|_| anyhow::anyhow!("Unable to read frame_offsets slice"))?;
269+
object::slice_from_bytes::<U32Bytes<LittleEndian>>(data, callsite_count).map_err(
270+
|_| wasmtime_environ::error::anyhow!("Unable to read frame_offsets slice"),
271+
)?;
271272
let (ranges, data) =
272273
object::slice_from_bytes::<U32Bytes<LittleEndian>>(data, callsite_count)
273-
.map_err(|_| anyhow::anyhow!("Unable to read ranges slice"))?;
274+
.map_err(|_| wasmtime_environ::error::anyhow!("Unable to read ranges slice"))?;
274275
let (tags, data) = object::slice_from_bytes::<U32Bytes<LittleEndian>>(data, handler_count)
275-
.map_err(|_| anyhow::anyhow!("Unable to read tags slice"))?;
276+
.map_err(|_| wasmtime_environ::error::anyhow!("Unable to read tags slice"))?;
276277
let (contexts, data) =
277278
object::slice_from_bytes::<U32Bytes<LittleEndian>>(data, handler_count)
278-
.map_err(|_| anyhow::anyhow!("Unable to read contexts slice"))?;
279+
.map_err(|_| wasmtime_environ::error::anyhow!("Unable to read contexts slice"))?;
279280
let (handlers, data) =
280281
object::slice_from_bytes::<U32Bytes<LittleEndian>>(data, handler_count)
281-
.map_err(|_| anyhow::anyhow!("Unable to read handlers slice"))?;
282+
.map_err(|_| wasmtime_environ::error::anyhow!("Unable to read handlers slice"))?;
282283

283284
if !data.is_empty() {
284-
anyhow::bail!("Unexpected data at end of serialized exception table");
285+
wasmtime_environ::error::bail!("Unexpected data at end of serialized exception table");
285286
}
286287

287288
Ok(ExceptionTable {

0 commit comments

Comments
 (0)