add enough errno variants to cover all windows codes too
This commit is contained in:
@@ -31,6 +31,9 @@ pub enum Error {
|
||||
/// Errno::Badf: Bad file descriptor
|
||||
#[error("Badf: Bad file descriptor")]
|
||||
Badf,
|
||||
/// Errno::Busy: Device or resource busy
|
||||
#[error("Busy: Device or resource busy")]
|
||||
Busy,
|
||||
/// Errno::Exist: File exists
|
||||
#[error("Exist: File exists")]
|
||||
Exist,
|
||||
@@ -64,9 +67,15 @@ pub enum Error {
|
||||
/// Errno::Nametoolong: Filename too long
|
||||
#[error("Nametoolong: Filename too long")]
|
||||
Nametoolong,
|
||||
/// Errno::Nfile: Too many files open in system
|
||||
#[error("Nfile: Too many files open in system")]
|
||||
Nfile,
|
||||
/// Errno::Noent: No such file or directory
|
||||
#[error("Noent: No such file or directory")]
|
||||
Noent,
|
||||
/// Errno::Nomem: Not enough space
|
||||
#[error("Nomem: Not enough space")]
|
||||
Nomem,
|
||||
/// Errno::Nospc: No space left on device
|
||||
#[error("Nospc: No space left on device")]
|
||||
Nospc,
|
||||
@@ -82,6 +91,9 @@ pub enum Error {
|
||||
/// Errno::Overflow: Value too large to be stored in data type.
|
||||
#[error("Overflow: Value too large to be stored in data type")]
|
||||
Overflow,
|
||||
/// Errno::Pipe: Broken pipe
|
||||
#[error("Pipe: Broken pipe")]
|
||||
Pipe,
|
||||
/// Errno::Perm: Operation not permitted
|
||||
#[error("Perm: Operation not permitted")]
|
||||
Perm,
|
||||
@@ -108,7 +120,6 @@ impl From<io::Error> for Error {
|
||||
fn from(err: io::Error) -> Self {
|
||||
match err.raw_os_error() {
|
||||
Some(code) => match code as u32 {
|
||||
winerror::ERROR_SUCCESS => Self::Success,
|
||||
winerror::ERROR_BAD_ENVIRONMENT => Self::TooBig,
|
||||
winerror::ERROR_FILE_NOT_FOUND => Self::Noent,
|
||||
winerror::ERROR_PATH_NOT_FOUND => Self::Noent,
|
||||
@@ -144,11 +155,14 @@ impl From<io::Error> for Error {
|
||||
fn from(err: io::Error) -> Self {
|
||||
match err.raw_os_error() {
|
||||
Some(code) => match code {
|
||||
libc::EPIPE => Self::Pipe,
|
||||
libc::EPERM => Self::Perm,
|
||||
libc::ENOENT => Self::Noent,
|
||||
libc::ENOMEM => Self::Nomem,
|
||||
libc::E2BIG => Self::TooBig,
|
||||
libc::EIO => Self::Io,
|
||||
libc::EBADF => Self::Badf,
|
||||
libc::EBUSY => Self::Busy,
|
||||
libc::EACCES => Self::Acces,
|
||||
libc::EFAULT => Self::Fault,
|
||||
libc::ENOTDIR => Self::Notdir,
|
||||
@@ -161,6 +175,7 @@ impl From<io::Error> for Error {
|
||||
libc::EMFILE => Self::Mfile,
|
||||
libc::EMLINK => Self::Mlink,
|
||||
libc::ENAMETOOLONG => Self::Nametoolong,
|
||||
libc::ENFILE => Self::Nfile,
|
||||
libc::ENOTEMPTY => Self::Notempty,
|
||||
libc::ELOOP => Self::Loop,
|
||||
libc::EOVERFLOW => Self::Overflow,
|
||||
|
||||
@@ -164,7 +164,7 @@ fn handle_rw_event(event: FdEventData, out_events: &mut Vec<types::Event>) {
|
||||
.as_file()
|
||||
.and_then(|f| f.metadata())
|
||||
.map(|m| m.len())
|
||||
.map_err(Into::into)
|
||||
.map_err(|ioerror| types::Errno::from(Error::from(ioerror)))
|
||||
} else {
|
||||
// The spec is unclear what nbytes should actually be for __WASI_EVENTTYPE_FD_WRITE and
|
||||
// the implementation on Unix just returns 0 here, so it's probably fine
|
||||
|
||||
@@ -39,6 +39,7 @@ impl From<Error> for Errno {
|
||||
Error::TooBig => Errno::TooBig,
|
||||
Error::Acces => Errno::Acces,
|
||||
Error::Badf => Errno::Badf,
|
||||
Error::Busy => Errno::Busy,
|
||||
Error::Exist => Errno::Exist,
|
||||
Error::Fault => Errno::Fault,
|
||||
Error::Fbig => Errno::Fbig,
|
||||
@@ -50,12 +51,15 @@ impl From<Error> for Errno {
|
||||
Error::Mfile => Errno::Mfile,
|
||||
Error::Mlink => Errno::Mlink,
|
||||
Error::Nametoolong => Errno::Nametoolong,
|
||||
Error::Nfile => Errno::Nfile,
|
||||
Error::Noent => Errno::Noent,
|
||||
Error::Nomem => Errno::Nomem,
|
||||
Error::Nospc => Errno::Nospc,
|
||||
Error::Notdir => Errno::Notdir,
|
||||
Error::Notempty => Errno::Notempty,
|
||||
Error::Notsup => Errno::Notsup,
|
||||
Error::Overflow => Errno::Overflow,
|
||||
Error::Pipe => Errno::Pipe,
|
||||
Error::Perm => Errno::Perm,
|
||||
Error::Spipe => Errno::Spipe,
|
||||
Error::Notcapable => Errno::Notcapable,
|
||||
|
||||
Reference in New Issue
Block a user