pchickey opened PR #5279 from pch/wasi_common_trappable_error
to main
.
pchickey edited PR #5279 from pch/wasi_common_trappable_error
to main
.
pchickey has marked PR #5279 as ready for review.
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-generatedsnapshots::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 ananyhow::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
andWasiDir
trait that it was a burden to ensure they only converted errors toanyhow::Error
which the corewasi-common
knew how to downcast into anErrno
.
pchickey updated PR #5279 from pch/wasi_common_trappable_error
to main
.
alexcrichton submitted PR review.
pchickey updated PR #5279 from pch/wasi_common_trappable_error
to main
.
pchickey merged PR #5279.
Last updated: Nov 22 2024 at 16:03 UTC