-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasi: introduce wasi.Errno type and switch error codes to constants (#72
- Loading branch information
1 parent
340e4d4
commit 5c23040
Showing
2 changed files
with
182 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,175 @@ | ||
package wasi | ||
|
||
import "fmt" | ||
|
||
// Errno is a type representing standard WASI error codes and implementing the | ||
// error interface. | ||
type Errno uint32 | ||
|
||
func (err Errno) Error() string { | ||
if int(err) < len(errnoToString) { | ||
return errnoToString[err] | ||
} | ||
return fmt.Sprintf("errno(%d)", uint32(err)) | ||
} | ||
|
||
// WASI error codes | ||
var ( | ||
ESUCCESS uint32 = 0 | ||
E2BIG uint32 = 1 /* Arg list too long */ | ||
EACCES uint32 = 2 /* Permission denied */ | ||
EADDRINUSE uint32 = 3 /* Address already in use */ | ||
EADDRNOTAVAIL uint32 = 4 /* Cannot assign requested address */ | ||
EAFNOSUPPORT uint32 = 5 /* Address family not supported by protocol */ | ||
EAGAIN uint32 = 6 /* Try again */ | ||
EALREADY uint32 = 7 /* Operation already in progress */ | ||
EBADF uint32 = 8 /* Bad file number */ | ||
EBADMSG uint32 = 9 | ||
EBUSY uint32 = 10 | ||
ECANCELED uint32 = 11 | ||
ECHILD uint32 = 12 | ||
ECONNABORTED uint32 = 13 | ||
ECONNREFUSED uint32 = 14 | ||
ECONNRESET uint32 = 15 | ||
EDEADLK uint32 = 16 | ||
EDESTADDRREQ uint32 = 17 | ||
EDOM uint32 = 18 | ||
EDQUOT uint32 = 19 | ||
EEXIST uint32 = 20 | ||
EFAULT uint32 = 21 | ||
EFBIG uint32 = 22 | ||
EHOSTUNREACH uint32 = 23 | ||
EIDRM uint32 = 24 | ||
EILSEQ uint32 = 25 | ||
EINPROGRESS uint32 = 26 | ||
EINTR uint32 = 27 | ||
EINVAL uint32 = 28 /* Invalid argument */ | ||
EIO uint32 = 29 | ||
EISCONN uint32 = 30 | ||
EISDIR uint32 = 31 | ||
ELOOP uint32 = 32 | ||
EMFILE uint32 = 33 | ||
EMLINK uint32 = 34 | ||
EMSGSIZE uint32 = 35 | ||
EMULTIHOP uint32 = 36 | ||
ENAMETOOLONG uint32 = 37 | ||
ENETDOWN uint32 = 38 | ||
ENETRESET uint32 = 39 | ||
ENETUNREACH uint32 = 40 | ||
ENFILE uint32 = 41 | ||
ENOBUFS uint32 = 42 | ||
ENODEV uint32 = 43 | ||
ENOENT uint32 = 44 | ||
ENOEXEC uint32 = 45 | ||
ENOLCK uint32 = 46 | ||
ENOLINK uint32 = 47 | ||
ENOMEM uint32 = 48 | ||
ENOMSG uint32 = 49 | ||
ENOPROTOOPT uint32 = 50 | ||
ENOSPC uint32 = 51 | ||
ENOSYS uint32 = 52 | ||
ENOTCONN uint32 = 53 | ||
ENOTDIR uint32 = 54 | ||
ENOTEMPTY uint32 = 55 | ||
ENOTRECOVERABLE uint32 = 56 | ||
ENOTSOCK uint32 = 57 | ||
ENOTSUP uint32 = 58 | ||
ENOTTY uint32 = 59 | ||
ENXIO uint32 = 60 | ||
EOVERFLOW uint32 = 61 | ||
EOWNERDEAD uint32 = 62 | ||
EPERM uint32 = 63 | ||
EPIPE uint32 = 64 | ||
EPROTO uint32 = 65 | ||
EPROTONOSUPPORT uint32 = 66 | ||
EPROTOTYPE uint32 = 67 | ||
ERANGE uint32 = 68 | ||
EROFS uint32 = 69 | ||
ESPIPE uint32 = 70 | ||
ESRCH uint32 = 71 | ||
ESTALE uint32 = 72 | ||
ETIMEDOUT uint32 = 73 | ||
ETXTBSY uint32 = 74 | ||
EXDEV uint32 = 75 | ||
ENOTCAPABLE uint32 = 76 | ||
const ( | ||
ESUCCESS Errno = 0 | ||
E2BIG Errno = 1 /* Arg list too long */ | ||
EACCES Errno = 2 /* Permission denied */ | ||
EADDRINUSE Errno = 3 /* Address already in use */ | ||
EADDRNOTAVAIL Errno = 4 /* Cannot assign requested address */ | ||
EAFNOSUPPORT Errno = 5 /* Address family not supported by protocol */ | ||
EAGAIN Errno = 6 /* Try again */ | ||
EALREADY Errno = 7 /* Operation already in progress */ | ||
EBADF Errno = 8 /* Bad file number */ | ||
EBADMSG Errno = 9 | ||
EBUSY Errno = 10 | ||
ECANCELED Errno = 11 | ||
ECHILD Errno = 12 | ||
ECONNABORTED Errno = 13 | ||
ECONNREFUSED Errno = 14 | ||
ECONNRESET Errno = 15 | ||
EDEADLK Errno = 16 | ||
EDESTADDRREQ Errno = 17 | ||
EDOM Errno = 18 | ||
EDQUOT Errno = 19 | ||
EEXIST Errno = 20 | ||
EFAULT Errno = 21 | ||
EFBIG Errno = 22 | ||
EHOSTUNREACH Errno = 23 | ||
EIDRM Errno = 24 | ||
EILSEQ Errno = 25 | ||
EINPROGRESS Errno = 26 | ||
EINTR Errno = 27 | ||
EINVAL Errno = 28 /* Invalid argument */ | ||
EIO Errno = 29 | ||
EISCONN Errno = 30 | ||
EISDIR Errno = 31 | ||
ELOOP Errno = 32 | ||
EMFILE Errno = 33 | ||
EMLINK Errno = 34 | ||
EMSGSIZE Errno = 35 | ||
EMULTIHOP Errno = 36 | ||
ENAMETOOLONG Errno = 37 | ||
ENETDOWN Errno = 38 | ||
ENETRESET Errno = 39 | ||
ENETUNREACH Errno = 40 | ||
ENFILE Errno = 41 | ||
ENOBUFS Errno = 42 | ||
ENODEV Errno = 43 | ||
ENOENT Errno = 44 | ||
ENOEXEC Errno = 45 | ||
ENOLCK Errno = 46 | ||
ENOLINK Errno = 47 | ||
ENOMEM Errno = 48 | ||
ENOMSG Errno = 49 | ||
ENOPROTOOPT Errno = 50 | ||
ENOSPC Errno = 51 | ||
ENOSYS Errno = 52 | ||
ENOTCONN Errno = 53 | ||
ENOTDIR Errno = 54 | ||
ENOTEMPTY Errno = 55 | ||
ENOTRECOVERABLE Errno = 56 | ||
ENOTSOCK Errno = 57 | ||
ENOTSUP Errno = 58 | ||
ENOTTY Errno = 59 | ||
ENXIO Errno = 60 | ||
EOVERFLOW Errno = 61 | ||
EOWNERDEAD Errno = 62 | ||
EPERM Errno = 63 | ||
EPIPE Errno = 64 | ||
EPROTO Errno = 65 | ||
EPROTONOSUPPORT Errno = 66 | ||
EPROTOTYPE Errno = 67 | ||
ERANGE Errno = 68 | ||
EROFS Errno = 69 | ||
ESPIPE Errno = 70 | ||
ESRCH Errno = 71 | ||
ESTALE Errno = 72 | ||
ETIMEDOUT Errno = 73 | ||
ETXTBSY Errno = 74 | ||
EXDEV Errno = 75 | ||
ENOTCAPABLE Errno = 76 | ||
) | ||
|
||
var errnoToString = [...]string{ | ||
ESUCCESS: "ESUCCESS", | ||
E2BIG: "E2BIG", | ||
EACCES: "EACCES", | ||
EADDRINUSE: "EADDRINUSE", | ||
EADDRNOTAVAIL: "EADDRNOTAVAIL", | ||
EAFNOSUPPORT: "EAFNOSUPPORT", | ||
EAGAIN: "EAGAIN", | ||
EALREADY: "EALREADY", | ||
EBADF: "EBADF", | ||
EBADMSG: "EBADMSG", | ||
EBUSY: "EBUSY", | ||
ECANCELED: "ECANCELED", | ||
ECHILD: "ECHILD", | ||
ECONNABORTED: "ECONNABORTED", | ||
ECONNREFUSED: "ECONNREFUSED", | ||
ECONNRESET: "ECONNRESET", | ||
EDEADLK: "EDEADLK", | ||
EDESTADDRREQ: "EDESTADDRREQ", | ||
EDOM: "EDOM", | ||
EDQUOT: "EDQUOT", | ||
EEXIST: "EEXIST", | ||
EFAULT: "EFAULT", | ||
EFBIG: "EFBIG", | ||
EHOSTUNREACH: "EHOSTUNREACH", | ||
EIDRM: "EIDRM", | ||
EILSEQ: "EILSEQ", | ||
EINPROGRESS: "EINPROGRESS", | ||
EINTR: "EINTR", | ||
EINVAL: "EINVAL", | ||
EIO: "EIO", | ||
EISCONN: "EISCONN", | ||
EISDIR: "EISDIR", | ||
ELOOP: "ELOOP", | ||
EMFILE: "EMFILE", | ||
EMLINK: "EMLINK", | ||
EMSGSIZE: "EMSGSIZE", | ||
EMULTIHOP: "EMULTIHOP", | ||
ENAMETOOLONG: "ENAMETOOLONG", | ||
ENETDOWN: "ENETDOWN", | ||
ENETRESET: "ENETRESET", | ||
ENETUNREACH: "ENETUNREACH", | ||
ENFILE: "ENFILE", | ||
ENOBUFS: "ENOBUFS", | ||
ENODEV: "ENODEV", | ||
ENOENT: "ENOENT", | ||
ENOEXEC: "ENOEXEC", | ||
ENOLCK: "ENOLCK", | ||
ENOLINK: "ENOLINK", | ||
ENOMEM: "ENOMEM", | ||
ENOMSG: "ENOMSG", | ||
ENOPROTOOPT: "ENOPROTOOPT", | ||
ENOSPC: "ENOSPC", | ||
ENOSYS: "ENOSYS", | ||
ENOTCONN: "ENOTCONN", | ||
ENOTDIR: "ENOTDIR", | ||
ENOTEMPTY: "ENOTEMPTY", | ||
ENOTRECOVERABLE: "ENOTRECOVERABLE", | ||
ENOTSOCK: "ENOTSOCK", | ||
ENOTSUP: "ENOTSUP", | ||
ENOTTY: "ENOTTY", | ||
ENXIO: "ENXIO", | ||
EOVERFLOW: "EOVERFLOW", | ||
EOWNERDEAD: "EOWNERDEAD", | ||
EPERM: "EPERM", | ||
EPIPE: "EPIPE", | ||
EPROTO: "EPROTO", | ||
EPROTONOSUPPORT: "EPROTONOSUPPORT", | ||
EPROTOTYPE: "EPROTOTYPE", | ||
ERANGE: "ERANGE", | ||
EROFS: "EROFS", | ||
ESPIPE: "ESPIPE", | ||
ESRCH: "ESRCH", | ||
ESTALE: "ESTALE", | ||
ETIMEDOUT: "ETIMEDOUT", | ||
ETXTBSY: "ETXTBSY", | ||
EXDEV: "EXDEV", | ||
ENOTCAPABLE: "ENOTCAPABLE", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters