-
Notifications
You must be signed in to change notification settings - Fork 18
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
Cadence Error Recovery #180
Comments
Hi Build Squad team! It is great to see interest in this area! The Cadence team has been thinking and investigating such a language feature for a while. Recently, investigations have become high priority in the hopes that it would allow users to force delete resources. The feature is very complex and uncertain, so it is unlikely that a grant for it is proposed or accepted. For example, such a feature has wide-ranging impact on the type system (e.g. resource typing) and the storage layer (support for snapshots and rollback). We are keen to work with the community and welcome collaboration. Currently we are discussing possibilities and we are planning to have breakout sessions for this topic soon. |
@turbolent Thanks for your answer 🙇 It was rather naive of me, to think that such a pattern was left out without a reason 🙈 But anyway I took a shot at it, as we're transitioning from only makings tools around Cadence, to also adding functionality to the language itself. The subtleties that you mentioned were rather difficult for us to grasp beforehand. |
@m-Peter Not at all! It's great to see there is both interest in the feature and making it a reality 🙌 |
Cadence Error Recovery
Grant category
Description
Cadence is the native programming language used for developing smart contracts / scripts / transactions that run on the Flow Blockchain. It comes with some handy built-in functions in its standard library, such as the panic function.
Problem statement
While working on improving the Cadence testing framework, we realized the need for a matcher that can allow / expect errors from Cadence code. This was not part of the grant's deliverables, however we proceeded with an implementation which has already been approved & merged. It then occurred to us, that this functionality is also missing from the Cadence standard library.
Proposed solution
Introduce a new standard library function (
recoverPanic
), which will enable error handling in Cadence. One functional prototype can be seen below:And its usage:
The above functionality is inspired from the RecoverErrors method defined on Cadence
Interpreter
, and can only be implemented natively.Impact
Error handling / recovery is a must-have for any programming language. Developers will be able to recover from
panic
calls that occur in other smart contracts, which in turn will result in better composability.Milestones and funding
recoverPanic
function along with tests/documentation/examplesThis is a follow-up to the addition of
Test.expectFailure
which has already been completed.Team
The text was updated successfully, but these errors were encountered: