-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathwasi_error.cr
254 lines (251 loc) · 11.2 KB
/
wasi_error.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
enum WasiError : UInt16
# Returns the system error message associated with this error code.
def message : String
case self
when SUCCESS then "No error occurred. System call completed successfully."
when TOOBIG then "Argument list too long."
when ACCES then "Permission denied."
when ADDRINUSE then "Address in use."
when ADDRNOTAVAIL then "Address not available."
when AFNOSUPPORT then "Address family not supported."
when AGAIN then "Resource unavailable, or operation would block."
when ALREADY then "Connection already in progress."
when BADF then "Bad file descriptor."
when BADMSG then "Bad message."
when BUSY then "Device or resource busy."
when CANCELED then "Operation canceled."
when CHILD then "No child processes."
when CONNABORTED then "Connection aborted."
when CONNREFUSED then "Connection refused."
when CONNRESET then "Connection reset."
when DEADLK then "Resource deadlock would occur."
when DESTADDRREQ then "Destination address required."
when DOM then "Mathematics argument out of domain of function."
when DQUOT then "Reserved."
when EXIST then "File exists."
when FAULT then "Bad address."
when FBIG then "File too large."
when HOSTUNREACH then "Host is unreachable."
when IDRM then "Identifier removed."
when ILSEQ then "Illegal byte sequence."
when INPROGRESS then "Operation in progress."
when INTR then "Interrupted function."
when INVAL then "Invalid argument."
when IO then "I/O error."
when ISCONN then "Socket is connected."
when ISDIR then "Is a directory."
when LOOP then "Too many levels of symbolic links."
when MFILE then "File descriptor value too large."
when MLINK then "Too many links."
when MSGSIZE then "Message too large."
when MULTIHOP then "Reserved."
when NAMETOOLONG then "Filename too long."
when NETDOWN then "Network is down."
when NETRESET then "Connection aborted by network."
when NETUNREACH then "Network unreachable."
when NFILE then "Too many files open in system."
when NOBUFS then "No buffer space available."
when NODEV then "No such device."
when NOENT then "No such file or directory."
when NOEXEC then "Executable file format error."
when NOLCK then "No locks available."
when NOLINK then "Reserved."
when NOMEM then "Not enough space."
when NOMSG then "No message of the desired type."
when NOPROTOOPT then "Protocol not available."
when NOSPC then "No space left on device."
when NOSYS then "Function not supported."
when NOTCONN then "The socket is not connected."
when NOTDIR then "Not a directory or a symbolic link to a directory."
when NOTEMPTY then "Directory not empty."
when NOTRECOVERABLE then "State not recoverable."
when NOTSOCK then "Not a socket."
when NOTSUP then "Not supported, or operation not supported on socket."
when NOTTY then "Inappropriate I/O control operation."
when NXIO then "No such device or address."
when OVERFLOW then "Value too large to be stored in data type."
when OWNERDEAD then "Previous owner died."
when PERM then "Operation not permitted."
when PIPE then "Broken pipe."
when PROTO then "Protocol error."
when PROTONOSUPPORT then "Protocol not supported."
when PROTOTYPE then "Protocol wrong type for socket."
when RANGE then "Result too large."
when ROFS then "Read-only file system."
when SPIPE then "Invalid seek."
when SRCH then "No such process."
when STALE then "Reserved."
when TIMEDOUT then "Connection timed out."
when TXTBSY then "Text file busy."
when XDEV then "Cross-device link."
when NOTCAPABLE then "Extension: Capabilities insufficient."
else "Unknown error."
end
end
# :nodoc:
def unsafe_message(&)
yield message.to_slice
end
# Transforms this `WasiError` value to the equivalent `Errno` value.
#
# This is only defined for some values. If no transformation is defined for
# a specific value, the default result is `Errno::EINVAL`.
def to_errno : Errno
case self
when TOOBIG then Errno::E2BIG
when ACCES then Errno::EACCES
when ADDRINUSE then Errno::EADDRINUSE
when ADDRNOTAVAIL then Errno::EADDRNOTAVAIL
when AFNOSUPPORT then Errno::EAFNOSUPPORT
when AGAIN then Errno::EAGAIN
when ALREADY then Errno::EALREADY
when BADF then Errno::EBADF
when BADMSG then Errno::EBADMSG
when BUSY then Errno::EBUSY
when CANCELED then Errno::ECANCELED
when CHILD then Errno::ECHILD
when CONNABORTED then Errno::ECONNABORTED
when CONNREFUSED then Errno::ECONNREFUSED
when CONNRESET then Errno::ECONNRESET
when DEADLK then Errno::EDEADLK
when DESTADDRREQ then Errno::EDESTADDRREQ
when DOM then Errno::EDOM
when DQUOT then Errno::EDQUOT
when EXIST then Errno::EEXIST
when FAULT then Errno::EFAULT
when FBIG then Errno::EFBIG
when HOSTUNREACH then Errno::EHOSTUNREACH
when IDRM then Errno::EIDRM
when ILSEQ then Errno::EILSEQ
when INPROGRESS then Errno::EINPROGRESS
when INTR then Errno::EINTR
when INVAL then Errno::EINVAL
when IO then Errno::EIO
when ISCONN then Errno::EISCONN
when ISDIR then Errno::EISDIR
when LOOP then Errno::ELOOP
when MFILE then Errno::EMFILE
when MLINK then Errno::EMLINK
when MSGSIZE then Errno::EMSGSIZE
when MULTIHOP then Errno::EMULTIHOP
when NAMETOOLONG then Errno::ENAMETOOLONG
when NETDOWN then Errno::ENETDOWN
when NETRESET then Errno::ENETRESET
when NETUNREACH then Errno::ENETUNREACH
when NFILE then Errno::ENFILE
when NOBUFS then Errno::ENOBUFS
when NODEV then Errno::ENODEV
when NOENT then Errno::ENOENT
when NOEXEC then Errno::ENOEXEC
when NOLCK then Errno::ENOLCK
when NOLINK then Errno::ENOLINK
when NOMEM then Errno::ENOMEM
when NOMSG then Errno::ENOMSG
when NOPROTOOPT then Errno::ENOPROTOOPT
when NOSPC then Errno::ENOSPC
when NOSYS then Errno::ENOSYS
when NOTCONN then Errno::ENOTCONN
when NOTDIR then Errno::ENOTDIR
when NOTEMPTY then Errno::ENOTEMPTY
when NOTRECOVERABLE then Errno::ENOTRECOVERABLE
when NOTSOCK then Errno::ENOTSOCK
when NOTSUP then Errno::ENOTSUP
when NOTTY then Errno::ENOTTY
when NXIO then Errno::ENXIO
when OVERFLOW then Errno::EOVERFLOW
when OWNERDEAD then Errno::EOWNERDEAD
when PERM then Errno::EPERM
when PIPE then Errno::EPIPE
when PROTO then Errno::EPROTO
when PROTONOSUPPORT then Errno::EPROTONOSUPPORT
when PROTOTYPE then Errno::EPROTOTYPE
when RANGE then Errno::ERANGE
when ROFS then Errno::EROFS
when SPIPE then Errno::ESPIPE
when SRCH then Errno::ESRCH
when STALE then Errno::ESTALE
when TIMEDOUT then Errno::ETIMEDOUT
when TXTBSY then Errno::ETXTBSY
when XDEV then Errno::EXDEV
when NOTCAPABLE then Errno::ENOTCAPABLE
else Errno::EINVAL
end
end
SUCCESS # No error occurred. System call completed successfully.
TOOBIG # Argument list too long.
ACCES # Permission denied.
ADDRINUSE # Address in use.
ADDRNOTAVAIL # Address not available.
AFNOSUPPORT # Address family not supported.
AGAIN # Resource unavailable, or operation would block.
ALREADY # Connection already in progress.
BADF # Bad file descriptor.
BADMSG # Bad message.
BUSY # Device or resource busy.
CANCELED # Operation canceled.
CHILD # No child processes.
CONNABORTED # Connection aborted.
CONNREFUSED # Connection refused.
CONNRESET # Connection reset.
DEADLK # Resource deadlock would occur.
DESTADDRREQ # Destination address required.
DOM # Mathematics argument out of domain of function.
DQUOT # Reserved.
EXIST # File exists.
FAULT # Bad address.
FBIG # File too large.
HOSTUNREACH # Host is unreachable.
IDRM # Identifier removed.
ILSEQ # Illegal byte sequence.
INPROGRESS # Operation in progress.
INTR # Interrupted function.
INVAL # Invalid argument.
IO # I/O error.
ISCONN # Socket is connected.
ISDIR # Is a directory.
LOOP # Too many levels of symbolic links.
MFILE # File descriptor value too large.
MLINK # Too many links.
MSGSIZE # Message too large.
MULTIHOP # Reserved.
NAMETOOLONG # Filename too long.
NETDOWN # Network is down.
NETRESET # Connection aborted by network.
NETUNREACH # Network unreachable.
NFILE # Too many files open in system.
NOBUFS # No buffer space available.
NODEV # No such device.
NOENT # No such file or directory.
NOEXEC # Executable file format error.
NOLCK # No locks available.
NOLINK # Reserved.
NOMEM # Not enough space.
NOMSG # No message of the desired type.
NOPROTOOPT # Protocol not available.
NOSPC # No space left on device.
NOSYS # Function not supported.
NOTCONN # The socket is not connected.
NOTDIR # Not a directory or a symbolic link to a directory.
NOTEMPTY # Directory not empty.
NOTRECOVERABLE # State not recoverable.
NOTSOCK # Not a socket.
NOTSUP # Not supported, or operation not supported on socket.
NOTTY # Inappropriate I/O control operation.
NXIO # No such device or address.
OVERFLOW # Value too large to be stored in data type.
OWNERDEAD # Previous owner died.
PERM # Operation not permitted.
PIPE # Broken pipe.
PROTO # Protocol error.
PROTONOSUPPORT # Protocol not supported.
PROTOTYPE # Protocol wrong type for socket.
RANGE # Result too large.
ROFS # Read-only file system.
SPIPE # Invalid seek.
SRCH # No such process.
STALE # Reserved.
TIMEDOUT # Connection timed out.
TXTBSY # Text file busy.
XDEV # Cross-device link.
NOTCAPABLE # Extension: Capabilities insufficient.
end