You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of being simple uint32, how about making the a type implementing the error interface. This would be useful to return error codes from custom implementations of the wasi.FS and wasi.File interfaces, which are otherwise converted to the generic EIO code in functions like fd_read or fd_write, for example https://github.com/tetratelabs/wazero/blob/main/wasi/wasi.go#L258
The error codes declared in errno.go would be declared as constants of the Errno type:
const (
ESUCCESSErrno=0...
)
The signature of functions like fd_read can then be modified to return an Errno value instead of a plain uint32. I believe this should remain compatible with the current implementation since the underlying type remains unchanged, the use of reflection to discover the function signature would keep seeing return values of kind reflect.Uint32.
Let me know if you have any concerns about it or I have overlooked implementation details, I can send a pull request if we agree the change would be useful.
The text was updated successfully, but these errors were encountered:
SGTM as well, thanks you @achille-roussel. Note that WASI code is not written by me but a contributor when this project was in hiatus period, so in anyway the WASI package needs refactoring! 🔥
I would really appreciate it if you could send a PR! Thanks in advance! 👍
Hello,
I'm opening this issue to discuss changing the way error codes in https://github.com/tetratelabs/wazero/blob/main/wasi/errno.go are represented.
Instead of being simple
uint32
, how about making the a type implementing theerror
interface. This would be useful to return error codes from custom implementations of thewasi.FS
andwasi.File
interfaces, which are otherwise converted to the genericEIO
code in functions likefd_read
orfd_write
, for example https://github.com/tetratelabs/wazero/blob/main/wasi/wasi.go#L258The
Errno
type would be defined as such:The error codes declared in errno.go would be declared as constants of the
Errno
type:The signature of functions like
fd_read
can then be modified to return anErrno
value instead of a plainuint32
. I believe this should remain compatible with the current implementation since the underlying type remains unchanged, the use of reflection to discover the function signature would keep seeing return values of kindreflect.Uint32
.Let me know if you have any concerns about it or I have overlooked implementation details, I can send a pull request if we agree the change would be useful.
The text was updated successfully, but these errors were encountered: