Error handling#976
Closed
R27-pixel wants to merge 2 commits into
Closed
Conversation
Member
|
This seems to be a duplicate of #931 |
Author
|
803d282 to
18941b4
Compare
18941b4 to
6c4f7f8
Compare
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.
Description and Notes
This PR replaces panicking
.unwrap(),.expect(), andassert!calls infloresta-watch-onlywith proper error propagation to prevent production aborts on recoverable failures.A new
WatchOnlyError::InsufficientBalance { address_balance, debit_value }variant was added to handle balance inconsistencies safely instead of panicking.Changes made
AddressCacheInner::new()now returnsResultand propagates database failures fromdatabase.load()anddatabase.save_stats()using?cache_transaction()now returnsResultand propagatessave_transaction()failures instead of using.expect()block_process()now returnsResultand propagates errors fromcache_transaction()using?BlockConsumer::on_block()logs errors usingtracing::error!instead of panickingsave_non_mempool_tx()now returnsResultand replacesassert!(value <= address.balance)withWatchOnlyError::InsufficientBalanceAddressCache::new()now returnsResultand propagates constructor errors properlyTests
Added
test_insufficient_balance_errorto verify that debiting more than an address’s recorded balance returnsWatchOnlyError::InsufficientBalanceinstead of panicking.How to verify the changes you have done?
Run: