refactor: Revert certain Throws by LogicErrors - #7036
Conversation
There was a problem hiding this comment.
Pull request overview
Reverts several low-level Ledger mutation invariants from Throw<std::logic_error> back to LogicError to ensure these failure paths abort cleanly (instead of throwing) when invoked from unprotected call stacks.
Changes:
- Replace
Throw<std::logic_error>withLogicErrorinLedger::rawErase(both overloads). - Replace
Throw<std::logic_error>withLogicErrorinLedger::rawInsert,Ledger::rawReplace, andLedger::rawTxInsert.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7036 +/- ##
=======================================
Coverage 82.1% 82.1%
=======================================
Files 1010 1010
Lines 75961 75951 -10
Branches 7392 7378 -14
=======================================
- Hits 62330 62322 -8
+ Misses 13631 13629 -2
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
High Level Overview of Change
This change reverts a few
Throwinstances toLogicError.Context of Change
In #6540 a number of
LogicError, which are[[noreturn]] noexceptthat callstd::abort(), were replaced withThrow<std::logic_error>(). While this works as expected in transactor code paths (protected by try-catch), the same replacement was applied toLedger::rawErase,Ledger::rawInsert,Ledger::rawReplace, andLedger::rawTxInsert, which are called from unprotected code paths.The above notwithstanding, this change is purely cosmetic, for the purpose of making the code "better" even though functionally there is no difference. Using
LogicErrorguarantees a cleanstd::abort()with no partial state; although usingThrowwould leave a local ledger in a partially modified state, since the local ledger is never written to disk it would not corrupt the ledger state.