Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTry to parse error messages to get an accurate error code for std/wasi #7626
Comments
|
Hello! Ill grab this one. |
|
@caspervonb hello! Is the example found here https://deno.land/std@0.72.0/wasi broken? I found where this change needs to go, but I'm not able to successfully run this example, even with the unstable flag.
|
|
Stricter WebAssembly definitions since a few releases ago, I should update that. Something like this would work. if (module.exports._start instanceof CallableFunction) {
instance.exports._start();
} else if (module.exports._initialize instanceof CallableFunction) {
instance.exports._initialize();
} else {
throw new Error("No entry point found");
} |
|
Altho in this case, I think the tests should just be in JavaScript testing that the conversion is correct localized to the syscall function. The upstream test suite doesn't enforce system conditions because in most cases it can't, the OS is really who decides what error it throws at us we just need to translate it. |
|
Just to be a bit more explicit, said attempt at parsing would go in this catch block. deno/std/wasi/snapshot_preview1.ts Lines 205 to 211 in e8b9367 There is probably an up to date mapping from POSIX errno to WASI errno in wasi-libc or rust libstd. |
This bit of a hack but it's what we can do at the moment without changing up the internal errors.
To get more accurate error mappings we can try to parse the errno from error message string which may contain the errno from Rust when it is an std::io::Error before falling back to the current approach of switching on error.name.
This is a good first issue.