kubkon opened PR #1242 from yanix-io-error
to master
:
This PR may seem somewhat controversial at first, but hear me
out first. Currently, Yanix would return a custom error that's a
wrapper around three other error types returned by various entities
inside Rust'slibstd
. In particular, Yanix's error type would wrap
io::Error
,num::TryFromIntError
andffi::NulError
. It turns
out that there is a natural conversion between the first and the last
and provided by the standard library, i.e.,From<ffi::NulError> for io::Error
is provided. So at the surface it may seem that only the first two
wrapped error types are worth keeping.Digging a little bit deeper into
libstd
,num::TryFromIntError
is essentially speaking only a marker that the integral conversion
went wrong. The struct implementing this error stores a unit type,
and nothing more. It therefore seems like a waste to wrap this
particular error when we could unify everything underio::Error
.
And so, whenever we perform an int conversion, I suggest we simply
remap the error toio::Error::from_raw_os_error(libc::EOVERFLOW)
since this carries a comparable amount of information.As a result of completely discarding
yanix::Error
custom error type,
we are invariably simplifyingyanix
itself, but also allowing
wasi-common
to simplify in several places as well.I'm curious to see what you guys reckon!
kubkon requested alexcrichton, and sunfishcode for a review on PR #1242.
kubkon requested alexcrichton, and sunfishcode for a review on PR #1242.
Last updated: Nov 22 2024 at 17:03 UTC