Mentioned here: #14461 (comment)
Current behavior is to assert(false) and crash, only info is printed in the log. This shows the message to the user before abort() instead.
Mentioned here: #14461 (comment)
Current behavior is to assert(false) and crash, only info is printed in the log. This shows the message to the user before abort() instead.
utACK 025afbe139684a467928958cebf1fb01930f5354
utACK 025afbe.
Is there a reason to not shutdown gracefully? And why is this a fatal error? Today we could jut unload it?
201 | @@ -201,8 +202,9 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) 202 | } 203 | if (keyPass && keyFail) 204 | { 205 | + uiInterface.ThreadSafeMessageBox(_("Error unlocking wallet. Your wallet file may be corrupt."), "", CClientUIInterface::MSG_ERROR);
Pretty ugly to call into the UI from such a low-level routine. Is it possible to instead return a failure status, and have the caller deal with this?
What @sipa said. Just returning an error state will prevent from unnecessary file/class-coupling
158 | - tr("The passphrase entered for the wallet decryption was incorrect.")); 159 | - } 160 | - else 161 | - { 162 | - QDialog::accept(); // Success 163 | + try {
I think this is as ugly as calling UI from low level, only inverted.
One alternative is to catch the exception in WalletImpl::unlock and return an error.
Orthogonally CCryptoKeyStore::Unlock could also return an error instead of assert(false).
I think this is as ugly as calling UI from low level, only inverted.
I don't think I understand why this ugly. Can you explain? Is the problem just that the code throws an exception instead of returning an error code?
Hope I can explain:
Since we don't use throw specifiers, I think typed errors are more readable.
Thanks for clarifying. It sounds like either switching to a return code, or switching from std::runtime_error to a specific exception type would address your concerns. I agree these things would be improvements. I'm also ok with current PR, though.
ignore my diatribe, but exceptions are just the cpp-ish way of goto. Especially with our wildcard catch blocks, this is hard to review and easy to break in the future. Less braindead programming languages like rust show that error handling can be done without exceptions or gotos.
166 | + tr("The passphrase entered for the wallet decryption was incorrect.")); 167 | + } else { 168 | + QDialog::accept(); // Success 169 | + } 170 | + } catch (const std::runtime_error& e) { 171 | + QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
The wallet remains loaded?
The wallet remains loaded?
This seems ok but it might be nice to add a code comment about why it's intended.
utACK 48062643f13b5442dec84cfa3d64e98e3815530b. Change since last review is replacing uiinterface callback and abort with an exception that gets bubbled up.
utACK 48062643f13b5442dec84cfa3d64e98e3815530b. Could squash?
Squashed 👍
utACK b4f6e58ca5a74225b6db9deb3ffe1ce3ab19a790. No changes since last review except to squash.
This change might be ready to merge.