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
Ability to catch exceptions #1505
Comments
Would it be possible to attach a label to the catch statement? Too general catch clauses have proven to be a constant source of bugs in many programs. Perhaps these tags could be translated to simple Sure, you don't need language support to do this, but given how difficult it is to get this kind of error handling right, I think it would be a welcome addition. |
The main problem to overcome is how to handle cross-call exceptions. |
@chriseth This can be solved by passing two return pointers on the stack. One for normal returning, and the other for exception throwing. |
With
This would be backwards compatible, because the higher level method still throws an exception, but the try clause will execute if the |
@axic Do you think cross-internal-call exception catching can be done in ewasm? |
I am a fan of the MVP: try {
Wallet(addr1).transferTo(addr2);
} catch {
// something didn't work
} In other news, I am not a fan of storing English-language error messages inside the blockchain. So I think this MVP is a final product. |
Hey all, I'm trying to impliment this for the Gnosis MultiSend, such that if one of the transactions fails, the MultiSend skips and continues with the next transaction, thoughts? I suppose I just remove the
|
Has been implemented for external calls in 0.6.0. |
A general
try { ... } catch
-statement should be available to catch exceptions.How to implement it: The "invalid label" has to become dynamic and somehow either the stack height has to be stored or it will be impossible to access local variables. Furthermore, we have to decide whether local effects should be reverted or not.
The text was updated successfully, but these errors were encountered: