Stream: git-wasmtime

Topic: wasmtime / PR #5279 Use wiggle "trappable error" to imple...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 01:00):

pchickey opened PR #5279 from pch/wasi_common_trappable_error to main.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 01:01):

pchickey edited PR #5279 from pch/wasi_common_trappable_error to main.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 01:43):

pchickey has marked PR #5279 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 01:49):

pchickey edited PR #5279 from pch/wasi_common_trappable_error to main:

Based on #5276

This PR replaces the use of anyhow::Error with a wiggle-generated snapshots::preview_1::types::Error throughout the wasi-common (and child) crates.

This change was ultimately for better type safety. The old conversion code https://github.com/bytecodealliance/wasmtime/pull/5279/files#diff-40a165c1f24fb0428d93215436730254f0379f22e816a70e0e29a44ba99c8be4L45-L66 from anyhow::Error to the concrete Errno type missed a downcast of cap_rand::Error, which gets convereted to an anyhow::Error here https://github.com/bytecodealliance/wasmtime/blob/91d1d20cb628bf7875199fe5f4a4b232933bdbcb/crates/wasi-common/src/snapshots/preview_1.rs#LL1036-L1036C5 since 2019, and I probably never would have discovered it if I hadn't tried refactoring the error representation to be more typesafe.

We're preparing wasi-common for the coming component-based preview 2, which will have (among other improvements) a wider range of errno types. With the increase in complexity, I was more worried about correctness than ergonomics. I also got reports from other crate authors implementing the WasiFile and WasiDir trait that it was a burden to ensure they only converted errors to anyhow::Error which the core wasi-common knew how to downcast into an Errno.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 17:29):

pchickey updated PR #5279 from pch/wasi_common_trappable_error to main.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 19:02):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 21:37):

pchickey updated PR #5279 from pch/wasi_common_trappable_error to main.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 17 2022 at 00:57):

pchickey merged PR #5279.


Last updated: Oct 23 2024 at 20:03 UTC