WASI icon indicating copy to clipboard operation
WASI copied to clipboard

Error codes from filesystem functions

Open zoraaver opened this issue 1 year ago • 4 comments

While attempting to fix the rust WASI tests on WAMR, I ran into various discrepancies between the expected error codes for various filesystem operations and the expected error codes (presumably suited for wasmtime).

Since we don't seem to document the returned error codes for the filesystem functions, I was wondering whether we should? If we don't want to explicitly document every error code for each condition, defaulting to POSIX might be another option. But I'm not sure if this is a) useful b) overly restrictive

Any thoughts or suggestions would be appreciated, thanks!

zoraaver avatar Sep 13 '23 15:09 zoraaver

I personally like the idea of having an error code consistency across runtimes/platforms, as that truly enables us to "write once, run everywhere" in the WASI world. Whereas there are cases where error codes are just for logging / debugging purpose, there are cases where they are actionable and code can rely on them.

Having said that, I do agree they introduce quite a bit of overhead in terms of documentation, so we'd need to do some incremental work to update all of that. I'm curious what approach is planned for preview2 interfaces - is there going to be a list of error codes for each function (e.g. filesystem, cc: @sunfishcode )?

loganek avatar Sep 13 '23 19:09 loganek

I agree with the idea of being consistent, but I wonder if this error code problem goes away due to using WIT to define preview2. Previously we had to share an error code space among many functions; now each function can return its own error enum that only contains the applicable error cases.

abrown avatar Sep 15 '23 21:09 abrown

I also agree this would be nice to do. If anyone is interested, I guess the first step is to start making lists of errors for each function.

sunfishcode avatar Sep 15 '23 22:09 sunfishcode

I agree with the idea of being consistent, but I wonder if this error code problem goes away due to using WIT to define preview2. Previously we had to share an error code space among many functions; now each function can return its own error enum that only contains the applicable error cases.

i guess it won't go away as far as we will support some mappings to posix api.

yamt avatar Sep 27 '23 09:09 yamt