Many exceptions thrown for corruption are std::runtime_error
; we should catch those and log the message to help with debugging.
Split from #32489
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32598.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | furszy, rkrux, davidgumberg, Sjors |
Concept ACK | jonatack |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
ACK 62ad4d80883191073ea39f8b8d5ccef0748414a1
Should also change HasLegacyRecords() as it would log the same error twice with this change.
That^ log can be removed as I checked that the only other usage of HasLegacyRecords
is directly inside the MigrateLegacyToDescriptor
function that comes after the corresponding LoadWallet
call. So, there should not be any informative log missing after its removal.
Should also change HasLegacyRecords() as it would log the same error twice with this change.
Done
1192@@ -1194,9 +1193,15 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
1193
1194 // Load decryption keys
1195 result = std::max(LoadDecryptionKeys(pwallet, *m_batch), result);
1196- } catch (...) {
1197+ } catch (std::runtime_error& e) {
1197+ } catch (std::runtime_error& e) {
1198 // Exceptions that can be ignored or treated as non-critical are handled by the individual loading functions.
1199 // Any uncaught exceptions will be caught here and treated as critical.
1200+ // Catch std::runtime_error specifically as many functions throw these and they at least have some message that
1201+ // we can log
1202+ pwallet->WalletLogPrintf("%s\n", e.what());
runtime_error
is extraordinarily generic.