Skip to content

Commit

Permalink
wallet: Improve log output for errors during load
Browse files Browse the repository at this point in the history
When loading the default wallet, display the wallet name in error messages as
"[default wallet]", instead of the empty string which gives confusing messages.

When an exception occurs during wallet loading, display e.what() if possible,
instead of nothing.
  • Loading branch information
gwillen committed Feb 27, 2019
1 parent d88f7f8 commit 4b4127b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Expand Up @@ -4097,7 +4097,7 @@ bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, b

std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain, const WalletLocation& location, uint64_t wallet_creation_flags)
{
const std::string& walletFile = location.GetName();
const std::string& walletFile = (location.GetName() == "" ? "[default wallet]" : location.GetName());

// needed to restore wallet transaction meta data after -zapwallettxes
std::vector<CWalletTx> vWtx;
Expand Down
9 changes: 9 additions & 0 deletions src/wallet/walletdb.cpp
Expand Up @@ -422,8 +422,17 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
strType != "minversion" && strType != "acentry") {
wss.m_unknown_records++;
}
} catch (const std::exception& e)
{
if (strErr == "") {
strErr = e.what();
}
return false;
} catch (...)
{
if (strErr == "") {
strErr = "Caught unknown exception in ReadKeyValue";
}
return false;
}
return true;
Expand Down

0 comments on commit 4b4127b

Please sign in to comment.