Skip to content

Commit 87ecf7f

Browse files
committed
Use io_error_more on WASI
1 parent 9fa6bdd commit 87ecf7f

File tree

1 file changed

+71
-13
lines changed
  • library/std/src/sys/wasi

1 file changed

+71
-13
lines changed

library/std/src/sys/wasi/mod.rs

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,82 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
8383
}
8484

8585
match errno {
86+
e if e == wasi::ERRNO_2BIG.raw().into() => ArgumentListTooLong,
87+
e if e == wasi::ERRNO_ACCES.raw().into() => PermissionDenied,
88+
e if e == wasi::ERRNO_ADDRINUSE.raw().into() => AddrInUse,
89+
e if e == wasi::ERRNO_ADDRNOTAVAIL.raw().into() => AddrNotAvailable,
90+
// wasi::ERRNO_AFNOSUPPORT.raw().into() => "address family not supported",
91+
e if e == wasi::ERRNO_AGAIN.raw().into() => WouldBlock,
92+
// wasi::ERRNO_ALREADY.raw().into() => "connection already in progress",
93+
// wasi::ERRNO_BADF.raw().into() => "bad file descriptor",
94+
// wasi::ERRNO_BADMSG.raw().into() => "bad message",
95+
e if e == wasi::ERRNO_BUSY.raw().into() => ResourceBusy,
96+
// wasi::ERRNO_CANCELED.raw().into() => "operation canceled",
97+
// wasi::ERRNO_CHILD.raw().into() => "no child processes",
98+
e if e == wasi::ERRNO_CONNABORTED.raw().into() => ConnectionAborted,
8699
e if e == wasi::ERRNO_CONNREFUSED.raw().into() => ConnectionRefused,
87100
e if e == wasi::ERRNO_CONNRESET.raw().into() => ConnectionReset,
88-
e if e == wasi::ERRNO_PERM.raw().into() || e == wasi::ERRNO_ACCES.raw().into() => {
89-
PermissionDenied
90-
}
91-
e if e == wasi::ERRNO_PIPE.raw().into() => BrokenPipe,
92-
e if e == wasi::ERRNO_NOTCONN.raw().into() => NotConnected,
93-
e if e == wasi::ERRNO_CONNABORTED.raw().into() => ConnectionAborted,
94-
e if e == wasi::ERRNO_ADDRNOTAVAIL.raw().into() => AddrNotAvailable,
95-
e if e == wasi::ERRNO_ADDRINUSE.raw().into() => AddrInUse,
96-
e if e == wasi::ERRNO_NOENT.raw().into() => NotFound,
101+
e if e == wasi::ERRNO_DEADLK.raw().into() => Deadlock,
102+
// wasi::ERRNO_DESTADDRREQ.raw().into() => "destination address required",
103+
// wasi::ERRNO_DOM.raw().into() => "mathematics argument out of domain of function",
104+
// wasi::ERRNO_DQUOT.raw().into() => "reserved",
105+
e if e == wasi::ERRNO_EXIST.raw().into() => AlreadyExists,
106+
// wasi::ERRNO_FAULT.raw().into() => "bad address",
107+
e if e == wasi::ERRNO_FBIG.raw().into() => FileTooLarge,
108+
e if e == wasi::ERRNO_HOSTUNREACH.raw().into() => HostUnreachable,
109+
// wasi::ERRNO_IDRM.raw().into() => "identifier removed",
110+
// wasi::ERRNO_ILSEQ.raw().into() => "illegal byte sequence",
111+
// wasi::ERRNO_INPROGRESS.raw().into() => "operation in progress",
97112
e if e == wasi::ERRNO_INTR.raw().into() => Interrupted,
98113
e if e == wasi::ERRNO_INVAL.raw().into() => InvalidInput,
99-
e if e == wasi::ERRNO_TIMEDOUT.raw().into() => TimedOut,
100-
e if e == wasi::ERRNO_EXIST.raw().into() => AlreadyExists,
101-
e if e == wasi::ERRNO_AGAIN.raw().into() => WouldBlock,
102-
e if e == wasi::ERRNO_NOSYS.raw().into() => Unsupported,
114+
e if e == wasi::ERRNO_IO.raw().into() => Uncategorized,
115+
// wasi::ERRNO_ISCONN.raw().into() => "socket is connected",
116+
e if e == wasi::ERRNO_ISDIR.raw().into() => IsADirectory,
117+
e if e == wasi::ERRNO_LOOP.raw().into() => FilesystemLoop,
118+
// wasi::ERRNO_MFILE.raw().into() => "file descriptor value too large",
119+
e if e == wasi::ERRNO_MLINK.raw().into() => TooManyLinks,
120+
// wasi::ERRNO_MSGSIZE.raw().into() => "message too large",
121+
// wasi::ERRNO_MULTIHOP.raw().into() => "reserved",
122+
e if e == wasi::ERRNO_NAMETOOLONG.raw().into() => InvalidFilename,
123+
e if e == wasi::ERRNO_NETDOWN.raw().into() => NetworkDown,
124+
// wasi::ERRNO_NETRESET.raw().into() => "connection aborted by network",
125+
e if e == wasi::ERRNO_NETUNREACH.raw().into() => NetworkUnreachable,
126+
// wasi::ERRNO_NFILE.raw().into() => "too many files open in system",
127+
// wasi::ERRNO_NOBUFS.raw().into() => "no buffer space available",
128+
e if e == wasi::ERRNO_NODEV.raw().into() => NotFound,
129+
e if e == wasi::ERRNO_NOENT.raw().into() => NotFound,
130+
e if e == wasi::ERRNO_NOEXEC.raw().into() => InvalidData,
131+
// wasi::ERRNO_NOLCK.raw().into() => "no locks available",
132+
// wasi::ERRNO_NOLINK.raw().into() => "reserved",
103133
e if e == wasi::ERRNO_NOMEM.raw().into() => OutOfMemory,
134+
// wasi::ERRNO_NOMSG.raw().into() => "no message of the desired type",
135+
// wasi::ERRNO_NOPROTOOPT.raw().into() => "protocol not available",
136+
e if e == wasi::ERRNO_NOSPC.raw().into() => StorageFull,
137+
e if e == wasi::ERRNO_NOSYS.raw().into() => Unsupported,
138+
e if e == wasi::ERRNO_NOTCONN.raw().into() => NotConnected,
139+
e if e == wasi::ERRNO_NOTDIR.raw().into() => NotADirectory,
140+
e if e == wasi::ERRNO_NOTEMPTY.raw().into() => DirectoryNotEmpty,
141+
// wasi::ERRNO_NOTRECOVERABLE.raw().into() => "state not recoverable",
142+
e if e == wasi::ERRNO_NOTSOCK.raw().into() => InvalidInput,
143+
e if e == wasi::ERRNO_NOTSUP.raw().into() => Unsupported,
144+
// wasi::ERRNO_NOTTY.raw().into() => "inappropriate I/O control operation",
145+
e if e == wasi::ERRNO_NXIO.raw().into() => NotFound,
146+
// wasi::ERRNO_OVERFLOW.raw().into() => "value too large to be stored in data type",
147+
// wasi::ERRNO_OWNERDEAD.raw().into() => "previous owner died",
148+
e if e == wasi::ERRNO_PERM.raw().into() => PermissionDenied,
149+
e if e == wasi::ERRNO_PIPE.raw().into() => BrokenPipe,
150+
// wasi::ERRNO_PROTO.raw().into() => "protocol error",
151+
e if e == wasi::ERRNO_PROTONOSUPPORT.raw().into() => Unsupported,
152+
e if e == wasi::ERRNO_PROTOTYPE.raw().into() => InvalidInput,
153+
// wasi::ERRNO_RANGE.raw().into() => "result too large",
154+
e if e == wasi::ERRNO_ROFS.raw().into() => ReadOnlyFilesystem,
155+
// wasi::ERRNO_SPIPE.raw().into() => "invalid seek",
156+
e if e == wasi::ERRNO_SRCH.raw().into() => NotFound,
157+
// wasi::ERRNO_STALE.raw().into() => "reserved",
158+
e if e == wasi::ERRNO_TIMEDOUT.raw().into() => TimedOut,
159+
e if e == wasi::ERRNO_TXTBSY.raw().into() => ResourceBusy,
160+
e if e == wasi::ERRNO_XDEV.raw().into() => CrossesDevices,
161+
e if e == wasi::ERRNO_NOTCAPABLE.raw().into() => PermissionDenied,
104162
_ => Uncategorized,
105163
}
106164
}

0 commit comments

Comments
 (0)