-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
381: Hook up error propagation r=lachlansneff a=lachlansneff You can now retrieve the error from a panicking or error-returning imported function. Example: ```rust #[derive(Debug)] struct ExitCode { code: i32, } fn do_panic(_ctx: &mut Ctx) -> Result<i32, ExitCode> { Err(ExitCode { code: 42 }) } // This wasm functions calls `do_panic`. let foo: Func<(), i32> = instance.func(...)?; let result = foo.call(); println!("result: {:?}", result); if let Err(RuntimeError::Error { data }) = result { if let Ok(exit_code) = data.downcast::<ExitCode>() { println!("exit code: {:?}", exit_code); } } ``` outputs: ``` result: Err(unknown error) exit code: ExitCode { code: 42 } ``` Co-authored-by: Lachlan Sneff <[email protected]>
- Loading branch information
Showing
15 changed files
with
240 additions
and
126 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
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
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
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
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
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
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
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
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
Oops, something went wrong.