Refactor error handling and recategorize errors#295
Merged
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. |
Member
Author
|
|
SupunS
approved these changes
Mar 10, 2023
Co-authored-by: Supun Setunga <supun.setunga@gmail.com>
turbolent
approved these changes
Mar 22, 2023
|
|
||
| if len(b) != storageIDSize { | ||
| return nil, NewStorageIDErrorf("incorrect storage id buffer length %d", len(b)) | ||
| id, err := NewStorageIDFromRawBytes(b) |
| // 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
LedgerBaseStorageSlabStorageTypeInfoValueStorableDigesterBuilderDigesterPluggable callback functions:
StorableDecoderTypeInfoDecoderValueComparatorStorableComparatorHashInputProviderArrayElementProviderMapElementProviderArrayIterationFuncMapEntryIterationFuncMapElementIterationFuncmainbranchFiles changedin the Github PR explorer