wasi-common error cleanup: part 1, yanix (#1226)
* Reuse std::io::Error for raw *nix errno This commit removes custom `yanix::Errno` and instead (as was previously suggested) reuses `std::io::Error` to generate and wrap raw *nix errno value. * Update wasi-common to use new Yanix error type This commit updates `wasi-common` to use new way of handling raw OS error in `yanix`; i.e., via re-use of `std::io::Error` instead of a custom `Errno` enum. * Fix formatting * Unwrap if io::Error created from raw OS error This commit calls `unwrap` on `err` if that one was created via `io::Error::last_os_error()`. It also refactors error matching in several syscalls on the BSD platform (mainly).
This commit is contained in:
@@ -101,9 +101,6 @@ pub enum Error {
|
||||
Wasi(#[from] WasiError),
|
||||
#[error("IO error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
#[cfg(unix)]
|
||||
#[error("Yanix error: {0}")]
|
||||
Yanix(#[from] yanix::YanixError),
|
||||
}
|
||||
|
||||
impl From<TryFromIntError> for Error {
|
||||
@@ -150,16 +147,6 @@ impl Error {
|
||||
};
|
||||
err.as_wasi_error()
|
||||
}
|
||||
#[cfg(unix)]
|
||||
Self::Yanix(err) => {
|
||||
use yanix::YanixError::*;
|
||||
let err: Self = match err {
|
||||
Errno(errno) => (*errno).into(),
|
||||
NulError(err) => err.into(),
|
||||
TryFromIntError(err) => (*err).into(),
|
||||
};
|
||||
err.as_wasi_error()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user