-
Notifications
You must be signed in to change notification settings - Fork 180
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
[FVM] Handle cadence ParentErrors #5272
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5272 +/- ##
==========================================
+ Coverage 55.59% 55.62% +0.03%
==========================================
Files 1002 1002
Lines 96658 96708 +50
==========================================
+ Hits 53733 53795 +62
+ Misses 38862 38845 -17
- Partials 4063 4068 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -61,3 +65,107 @@ func TestErrorHandling(t *testing.T) { | |||
require.True(t, IsFailure(e1)) | |||
}) | |||
} | |||
|
|||
func TestHandleRuntimeError(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Co-authored-by: Leo Zhang <zhangchiqing@gmail.com>
I have to spend some time reviewing how the new error handling (coded) works on the FVM side before reviewing this, but before that out of curiosity why not fixing this on the cadence runtime? |
So there were 2 issues addressed here:
for example, in the below case the existing code would only see
By separating |
I don't know enough about FVM, so can't really review the PR, but in general, thank you for cleaning up and improving the categorization of errors 🙏 As far as I understand, "errors" are implementation errors (e.g. file can't be opened) and "failures" are user errors (e.g. the user ran out of computation units)? |
It's the opposite. "failures" are exceptions, and "errors" are recoverable errors. |
…ors-fvm [FVM] Handle cadence ParentErrors
Cadence
errors.ParentErrors
contain a list of errors encountered during execution:https://github.com/onflow/cadence/blob/5ce1f36f95bb458f05d03283c0af307ff7f6fe1e/runtime/errors/errors.go#L101-L104
These errors have an
Unwrap()
method that returns an[]error
instead of a plainerror
. This results in a tree of errors instead of a chain. While this is supported by the standarderrors.Is
anderrors.As
methods, theCodedError
type is overloaded for use by both normal errors and failures. This means that if there is a failure mixed with other errors, the failure could be missed since searching would stop at the first instance of aCodedError
.This PR refactors the FVM
CodedError
to add a new type for failures:CodedFailure
. This allowserrors.As
to find any instance of a failure within the error tree without custom logic.