kubkon opened PR #1253 from error-cleanup
to master
:
This PR builds on #1243.
WasiCtxBuilderError
is thewasi-common
client-facing error type which is exclusively thrown when building a newWasiCtx
instance. As such, building such an instance should not require the client to understand different WASI errno values as was assumed until now.This commit is a first step at streamlining error handling in
wasi-common
and makes way for thewiggle
crate.When adding the
WasiCtxBuilderError
, I've had to do two things of notable importance:
- I've removed a couple of
ok_or
calls inWasiCtxBuilder::build
and replaced them withunwrap
s, following the same pattern in different builder methods above. This is fine since we _always_ operate on non-emptyOption
s inWasiCtxBuilder
thusunwrap
ing will never fail. On the other hand, this might be a good opportunity to rethink the structure of our builder, and how we good remove the saidOption
s especially since we always populate them with empty containers to begin with. I understand this is to make chaining of builder methods easier which take and return&mut self
and the same applies toWasiCtxBuilder::build(&mut self)
method, but perhaps it would more cleanly signal the intentions if we simply movedWasiCtxBuilder
instance around. Food for thought!- Methods specific to determining rights of passed around
std::fs::File
objects when populatingWasiCtx
FdEntry
entities now returnio::Error
directly so that we can reuse them inWasiCtxBuilder
methods (returningWasiCtxBuilderError
error type), and in syscalls (returning WASI errno).ToDo:
- [x] introduce
WasiCtxBuilderError
- [ ] return
WasiError
directly in syscalls- [ ] hence remove
error::Error
type- [ ] fix
wig
kubkon requested alexcrichton, pchickey, and sunfishcode for a review on PR #1253.
kubkon requested alexcrichton, pchickey, and sunfishcode for a review on PR #1253.
kubkon requested alexcrichton, pchickey, and sunfishcode for a review on PR #1253.
kubkon updated PR #1253 from error-cleanup
to master
:
This PR builds on #1243.
WasiCtxBuilderError
is thewasi-common
client-facing error type which is exclusively thrown when building a newWasiCtx
instance. As such, building such an instance should not require the client to understand different WASI errno values as was assumed until now.This commit is a first step at streamlining error handling in
wasi-common
and makes way for thewiggle
crate.When adding the
WasiCtxBuilderError
, I've had to do two things of notable importance:
- I've removed a couple of
ok_or
calls inWasiCtxBuilder::build
and replaced them withunwrap
s, following the same pattern in different builder methods above. This is fine since we _always_ operate on non-emptyOption
s inWasiCtxBuilder
thusunwrap
ing will never fail. On the other hand, this might be a good opportunity to rethink the structure of our builder, and how we good remove the saidOption
s especially since we always populate them with empty containers to begin with. I understand this is to make chaining of builder methods easier which take and return&mut self
and the same applies toWasiCtxBuilder::build(&mut self)
method, but perhaps it would more cleanly signal the intentions if we simply movedWasiCtxBuilder
instance around. Food for thought!- Methods specific to determining rights of passed around
std::fs::File
objects when populatingWasiCtx
FdEntry
entities now returnio::Error
directly so that we can reuse them inWasiCtxBuilder
methods (returningWasiCtxBuilderError
error type), and in syscalls (returning WASI errno).ToDo:
- [x] introduce
WasiCtxBuilderError
- [ ] return
WasiError
directly in syscalls- [ ] hence remove
error::Error
type- [ ] fix
wig
kubkon edited PR #1253 from error-cleanup
to master
:
This PR builds on #1243.
WasiCtxBuilderError
is thewasi-common
client-facing error type which is exclusively thrown when building a newWasiCtx
instance. As such, building such an instance should not require the client to understand different WASI errno values as was assumed until now.This commit is a first step at streamlining error handling in
wasi-common
and makes way for thewiggle
crate.When adding the
WasiCtxBuilderError
, I've had to do two things of notable importance:
- I've removed a couple of
ok_or
calls inWasiCtxBuilder::build
and replaced them withunwrap
s, following the same pattern in different builder methods above. This is fine since we _always_ operate on non-emptyOption
s inWasiCtxBuilder
thusunwrap
ing will never fail. On the other hand, this might be a good opportunity to rethink the structure of our builder, and how we good remove the saidOption
s especially since we always populate them with empty containers to begin with. I understand this is to make chaining of builder methods easier which take and return&mut self
and the same applies toWasiCtxBuilder::build(&mut self)
method, but perhaps it would more cleanly signal the intentions if we simply movedWasiCtxBuilder
instance around. Food for thought!- Methods specific to determining rights of passed around
std::fs::File
objects when populatingWasiCtx
FdEntry
entities now returnio::Error
directly so that we can reuse them inWasiCtxBuilder
methods (returningWasiCtxBuilderError
error type), and in syscalls (returning WASI errno).ToDo:
- [x] introduce
WasiCtxBuilderError
- [ ] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [ ] fix
wig
kubkon edited PR #1253 from error-cleanup
to master
:
This PR builds on #1243.
WasiCtxBuilderError
is thewasi-common
client-facing error type which is exclusively thrown when building a newWasiCtx
instance. As such, building such an instance should not require the client to understand different WASI errno values as was assumed until now.This commit is a first step at streamlining error handling in
wasi-common
and makes way for thewiggle
crate.When adding the
WasiCtxBuilderError
, I've had to do two things of notable importance:
- I've removed a couple of
ok_or
calls inWasiCtxBuilder::build
and replaced them withunwrap
s, following the same pattern in different builder methods above. This is fine since we _always_ operate on non-emptyOption
s inWasiCtxBuilder
thusunwrap
ing will never fail. On the other hand, this might be a good opportunity to rethink the structure of our builder, and how we good remove the saidOption
s especially since we always populate them with empty containers to begin with. I understand this is to make chaining of builder methods easier which take and return&mut self
and the same applies toWasiCtxBuilder::build(&mut self)
method, but perhaps it would more cleanly signal the intentions if we simply movedWasiCtxBuilder
instance around. Food for thought!- Methods specific to determining rights of passed around
std::fs::File
objects when populatingWasiCtx
FdEntry
entities now returnio::Error
directly so that we can reuse them inWasiCtxBuilder
methods (returningWasiCtxBuilderError
error type), and in syscalls (returning WASI errno).ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [ ] fix
wig
kubkon edited PR #1253 from error-cleanup
to master
:
This PR builds on #1243.
WasiCtxBuilderError
is thewasi-common
client-facing error type which is exclusively thrown when building a newWasiCtx
instance. As such, building such an instance should not require the client to understand different WASI errno values as was assumed until now.This commit is a first step at streamlining error handling in
wasi-common
and makes way for thewiggle
crate.When adding the
WasiCtxBuilderError
, I've had to do two things of notable importance:
- I've removed a couple of
ok_or
calls inWasiCtxBuilder::build
and replaced them withunwrap
s, following the same pattern in different builder methods above. This is fine since we _always_ operate on non-emptyOption
s inWasiCtxBuilder
thusunwrap
ing will never fail. On the other hand, this might be a good opportunity to rethink the structure of our builder, and how we good remove the saidOption
s especially since we always populate them with empty containers to begin with. I understand this is to make chaining of builder methods easier which take and return&mut self
and the same applies toWasiCtxBuilder::build(&mut self)
method, but perhaps it would more cleanly signal the intentions if we simply movedWasiCtxBuilder
instance around. Food for thought!- Methods specific to determining rights of passed around
std::fs::File
objects when populatingWasiCtx
FdEntry
entities now returnio::Error
directly so that we can reuse them inWasiCtxBuilder
methods (returningWasiCtxBuilderError
error type), and in syscalls (returning WASI errno).ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
kubkon edited PR #1253 from error-cleanup
to master
:
WasiCtxBuilderError
is thewasi-common
client-facing error type which is exclusively thrown when building a newWasiCtx
instance. As such, building such an instance should not require the client to understand different WASI errno values as was assumed until now.This commit is a first step at streamlining error handling in
wasi-common
and makes way for thewiggle
crate.When adding the
WasiCtxBuilderError
, I've had to do two things of notable importance:
- I've removed a couple of
ok_or
calls inWasiCtxBuilder::build
and replaced them withunwrap
s, following the same pattern in different builder methods above. This is fine since we _always_ operate on non-emptyOption
s inWasiCtxBuilder
thusunwrap
ing will never fail. On the other hand, this might be a good opportunity to rethink the structure of our builder, and how we good remove the saidOption
s especially since we always populate them with empty containers to begin with. I understand this is to make chaining of builder methods easier which take and return&mut self
and the same applies toWasiCtxBuilder::build(&mut self)
method, but perhaps it would more cleanly signal the intentions if we simply movedWasiCtxBuilder
instance around. Food for thought!- Methods specific to determining rights of passed around
std::fs::File
objects when populatingWasiCtx
FdEntry
entities now returnio::Error
directly so that we can reuse them inWasiCtxBuilder
methods (returningWasiCtxBuilderError
error type), and in syscalls (returning WASI errno).With
WasiCtxBuilderError
in place, we now can return a pureWasiError
in all syscalls-related functions. This means we can completely removeerror::Error
type, and now,io::Error
and
related are automatically converted to their corresponding WASI errno value encapsulated asWasiError
. IMHO this makes tracking errors in syscalls a lot cleaner and simpler.While here, it also made sense to me to move
WasiError
towasi
module which will align itself well with the upcoming changes introduced bywiggle
. To different standardResult
from WASI specific, I've created a helper aliasWasiResult
also residing inwasi
module.Prereqs:
OK, while technically we only depend on #1243 since we're rebased on it, it'd be best if we landed #1255 before as well. So:
- [ ] #1243 landed
- [ ] #1255 landed
ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
Last updated: Dec 23 2024 at 12:05 UTC