I'm running a WASM module like this:
let result_result = command.wasi_cli_run().call_run(&mut store).await;
call_run() is unfortunately completely undocumented ("Run the program" doesn't add anything), and the return type is very unobvious: Result<Result<(), ()>>. Expanding the Results it's actually anyhow::Result<std::result::Result<(), ()>>.
So I think there are two sources of possible error from this run, which probably explains the nested Results:
- Some kind of error loading the module or with the bytecode or whatever.
- The module returns a non-zero exit code.
I assumed that the inner Result<(), ()> would handle the latter case, but actually non-zero exit codes result in the outer anyhow::Result<> containing the error.
That's very surprising and kind of awkward because there's no way to access the exit code either. I would have expected a return type of anyhow::Result<ExitStatus> surely?