Skip to content

Commit

Permalink
Merge pull request #4619 from wasmerio/wasix-more-errors
Browse files Browse the repository at this point in the history
feat(wasix): More improvements to spawn error propagation
  • Loading branch information
syrusakbary committed Apr 26, 2024
2 parents 6f1ba98 + fb3f487 commit db77dd1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/wasix/src/lib.rs
Expand Up @@ -155,8 +155,8 @@ pub enum SpawnError {
#[error("unsupported")]
Unsupported,
/// Not found
#[error("not found")]
NotFound,
#[error("not found: {message}")]
NotFound { message: String },
/// Tried to run the specified binary as a new WASI thread/process, but
/// the binary name was not found.
#[error("could not find binary '{binary}'")]
Expand Down Expand Up @@ -240,7 +240,7 @@ impl SpawnError {
/// [`NotFound`]: SpawnError::NotFound
#[must_use]
pub fn is_not_found(&self) -> bool {
matches!(self, Self::NotFound)
matches!(self, Self::NotFound { .. } | Self::MissingEntrypoint { .. })
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/wasix/src/os/console/mod.rs
Expand Up @@ -202,7 +202,9 @@ impl Console {
.ok();
});
tracing::debug!(error=?e, %webc, "failed to get webc dependency");
return Err(SpawnError::NotFound);
return Err(SpawnError::NotFound {
message: e.to_string(),
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/wasix/src/syscalls/mod.rs
Expand Up @@ -1507,8 +1507,8 @@ pub(crate) fn _prepare_wasi(wasi_env: &mut WasiEnv, args: Option<Vec<String>>) {
pub(crate) fn conv_spawn_err_to_errno(err: &SpawnError) -> Errno {
match err {
SpawnError::AccessDenied => Errno::Access,
SpawnError::NotFound => Errno::Noent,
SpawnError::Unsupported => Errno::Noexec,
_ if err.is_not_found() => Errno::Noent,
_ => Errno::Inval,
}
}
Expand Down

0 comments on commit db77dd1

Please sign in to comment.