-
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
Refactor error handling and recategorize errors #295
Conversation
Categorized errors into FatalError, ExternalError, and UserError. FatalError, ExternalError, and UserError implement Unwrap(). The word "pluggable" here describes interfaces or callback functions that can potentially be implemented by external packages. Basically, when Atree: - creates an error, create either FatalError or UserError. - receives error from known packages, wrap the error in FatalError or UserError. - receives error from pluggable interfaces or callback functions, wrap the error as ExternalError only if it is not categorized already. - receives error from its own functions, then there's no need to categorize error because it's already categorized. Just wrap the error with more context if needed. Pluggable interfaces include: - Ledger - BaseStorage - SlabStorage - TypeInfo - Value - Storable - DigesterBuilder - Digester Pluggable callback functions include: - StorableDecoder - TypeInfoDecoder - ValueComparator - StorableComparator - HashInputProvider - ArrayElementProvider - MapElementProvider - ArrayIterationFunc - MapEntryIterationFunc - MapElementIterationFunc
Codecov Report
@@ Coverage Diff @@
## main #295 +/- ##
==========================================
- Coverage 69.05% 64.62% -4.44%
==========================================
Files 14 14
Lines 7314 7991 +677
==========================================
+ Hits 5051 5164 +113
- Misses 1629 2152 +523
- Partials 634 675 +41
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
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.
🚀
Co-authored-by: Supun Setunga <supun.setunga@gmail.com>
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.
Great and thorough work! 👏
} | ||
|
||
if len(b) != storageIDSize { | ||
return nil, NewStorageIDErrorf("incorrect storage id buffer length %d", len(b)) | ||
id, err := NewStorageIDFromRawBytes(b) |
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.
👍
@@ -552,11 +575,23 @@ func (e *singleElement) Get(storage SlabStorage, _ Digester, _ uint, _ Digest, c | |||
// | |||
// Rehashing only happens when we create new inlineCollisionGroup. | |||
// Adding new element to existing inlineCollisionGroup doesn't require rehashing. | |||
func (e *singleElement) Set(storage SlabStorage, address Address, b DigesterBuilder, digester Digester, level uint, hkey Digest, comparator ValueComparator, hip HashInputProvider, key Value, value Value) (element, MapValue, error) { | |||
func (e *singleElement) Set( |
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.
👌
Changes
This PR improves error handling and error passing between Atree, Cadence, and FVM.
FatalError
,ExternalError
, andUserError
.Unwrap()
forFatalError
,ExternalError
, andUserError
.Closes #285
Updates onflow/cadence#1255
Details
Errors are categorized as early as feasible. Changes only affect the error paths (avoids affecting the happy paths).
Here, the word "pluggable" describes interfaces or callback functions that might be implemented by packages external to Atree.
Basically, when Atree:
Pluggable interfaces:
Ledger
BaseStorage
SlabStorage
TypeInfo
Value
Storable
DigesterBuilder
Digester
Pluggable callback functions:
StorableDecoder
TypeInfoDecoder
ValueComparator
StorableComparator
HashInputProvider
ArrayElementProvider
MapElementProvider
ArrayIterationFunc
MapEntryIterationFunc
MapElementIterationFunc
main
branchFiles changed
in the Github PR explorer