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
kubkon updated 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
sunfishcode submitted PR Review.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
This is a super minor nit, but it feels awkward to me to return
Utf8Error
as its own arm ofWasiCtxBuilderResult
while mappingNulError
toio::Error
. Also, theNulError
s we get don't arise from doing any actual I/O. What would you think of adding a newWasiCtxBuilderError
arm for this?
sunfishcode created PR Review Comment:
Is this used in this patch?
sunfishcode created PR Review Comment:
These errors are likely to be fairly visible, and unlike POSIX where ENOTDIR is typically returned from simple system calls where you can pretty much guess which thing it was that wasn't a directory that should have been, these are returned from WasiCtxBuilder::build, which does many things. So I suggest adding a path field to this error and making the message more specific, mentioning that this is about the preopens. Something like "Preopen directory path {} is not a directory", so that it's clear what the problem is.
kubkon submitted PR Review.
kubkon created PR Review Comment:
Ah, excellent catch! A leftover from prior attempts, thanks!
kubkon submitted PR Review.
kubkon created PR Review Comment:
Makes sense! Lemme fix then!
kubkon submitted PR Review.
kubkon created PR Review Comment:
I totally agree! The more info we can pass back to the client at this stage, the better!
kubkon updated 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
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:
- [x] #1243 landed
- [ ] #1255 landed
ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
kubkon updated 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:
- [x] #1243 landed
- [ ] #1255 landed
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:
- [x] #1243 landed
- [x] #1255 landed
ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
kubkon updated 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:
- [x] #1243 landed
- [x] #1255 landed
ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
kubkon requested alexcrichton, pchickey, and sunfishcode for a review on PR #1253.
kubkon updated 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:
- [x] #1243 landed
- [x] #1255 landed
ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
sunfishcode submitted PR Review.
kubkon updated 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:
- [x] #1243 landed
- [x] #1255 landed
ToDo:
- [x] introduce
WasiCtxBuilderError
- [x] return
WasiError
directly in syscalls- [x] hence remove
error::Error
type- [x] fix
wig
kubkon merged PR #1253.
Last updated: Dec 23 2024 at 13:07 UTC