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