-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error handling #58
Comments
Note, this would be a breaking change, but since you're still in version |
Yes. Returning a |
Any update on this? Thanks. |
@mattjohnsonpint I made a near zero-cost class to handle errors. Its inspired by Rust's Most of the work on this is happening in the |
Thanks! I'll review soon. |
@mattjohnsonpint I think this will be a better option To try it, just add the transform to your try {
// Do something
abort("Failed to execute!");
} catch (e) {
console.log("Got an error: " + e);
} finally {
console.log("Gracefully shutting down...");
} |
TODO |
Going to be released in |
If serialization or deserialization fails, this library throws an error.
In other languages this would be fine, because you could use try/catch to handle the error. Unfortunately, AssemblyScript doesn't yet support try/catch.
Even worse, if you throw an error, the AssemblyScript compiler calls
abort
, then writes a wasmunreachable
statement. That means even if you overrideabort
, you are still screwed because memory can become corrupted if you continue to use a module after anunreachable
. See AssemblyScript/assemblyscript#302 (comment)Instead of throwing, can you please return
null
, or perhaps return anOptional
orResult
type as a wrapper, etc.The text was updated successfully, but these errors were encountered: