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:
@@ -16,25 +16,12 @@ pub mod file;
|
||||
pub mod poll;
|
||||
pub mod socket;
|
||||
|
||||
mod errno;
|
||||
mod error;
|
||||
mod sys;
|
||||
|
||||
pub mod fadvise {
|
||||
pub use super::sys::fadvise::*;
|
||||
}
|
||||
|
||||
pub use errno::Errno;
|
||||
use std::{ffi, num};
|
||||
use thiserror::Error;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, YanixError>;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum YanixError {
|
||||
#[error("raw os error {0}")]
|
||||
Errno(#[from] Errno),
|
||||
#[error("a nul byte was not found in the expected position")]
|
||||
NulError(#[from] ffi::NulError),
|
||||
#[error("integral type conversion failed")]
|
||||
TryFromIntError(#[from] num::TryFromIntError),
|
||||
}
|
||||
pub use error::Error;
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
Reference in New Issue
Block a user