From 15643b7951d037de81ff1d050732b10343a61353 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 15 Mar 2022 14:23:30 +0100 Subject: [PATCH] qt init: make sure wallet file parsing errors are shown in gui Some exceptions were just killing the gui silently and not even logged. E.g.: ``` E | gui.qt.ElectrumGui | error loading wallet (or creating window for it) Traceback (most recent call last): File "/opt/electrum/electrum/gui/qt/__init__.py", line 433, in main if not self.start_new_window(path, self.config.get('url'), app_is_starting=True): File "/opt/electrum/electrum/gui/qt/__init__.py", line 307, in wrapper return func(self, *args, **kwargs) File "/opt/electrum/electrum/gui/qt/__init__.py", line 332, in start_new_window wallet = self._start_wizard_to_select_or_create_wallet(path) File "/opt/electrum/electrum/gui/qt/__init__.py", line 377, in _start_wizard_to_select_or_create_wallet db = WalletDB(storage.read(), manual_upgrades=False) File "/opt/electrum/electrum/wallet_db.py", line 73, in __init__ self.load_data(raw) File "/opt/electrum/electrum/wallet_db.py", line 104, in load_data self._after_upgrade_tasks() File "/opt/electrum/electrum/wallet_db.py", line 202, in _after_upgrade_tasks self._load_transactions() File "/opt/electrum/electrum/util.py", line 439, in return lambda *args, **kw_args: do_profile(args, kw_args) File "/opt/electrum/electrum/util.py", line 435, in do_profile o = func(*args, **kw_args) File "/opt/electrum/electrum/wallet_db.py", line 1310, in _load_transactions self.data = StoredDict(self.data, self, []) File "/opt/electrum/electrum/json_db.py", line 79, in __init__ self.__setitem__(k, v) File "/opt/electrum/electrum/json_db.py", line 44, in wrapper return func(self, *args, **kwargs) File "/opt/electrum/electrum/json_db.py", line 97, in __setitem__ v = self.db._convert_dict(self.path, key, v) File "/opt/electrum/electrum/wallet_db.py", line 1361, in _convert_dict v = dict((k, SwapData(**x)) for k, x in v.items()) ``` --- electrum/gui/qt/__init__.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index 05e89d4d7..0eab2af27 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -324,22 +324,15 @@ class ElectrumGui(BaseElectrumGui, Logger): parent=None, title=_('Error'), text=_('Cannot load wallet') + ' (1):\n' + repr(e)) - # if app is starting, still let wizard to appear + # if app is starting, still let wizard appear if not app_is_starting: return - if not wallet: - try: - wallet = self._start_wizard_to_select_or_create_wallet(path) - except (WalletFileException, BitcoinException) as e: - self.logger.exception('') - custom_message_box(icon=QMessageBox.Warning, - parent=None, - title=_('Error'), - text=_('Cannot load wallet') + ' (2):\n' + repr(e)) - if not wallet: - return - # create or raise window try: + if not wallet: + wallet = self._start_wizard_to_select_or_create_wallet(path) + if not wallet: + return + # create or raise window for window in self.windows: if window.wallet.storage.path == wallet.storage.path: break @@ -350,7 +343,7 @@ class ElectrumGui(BaseElectrumGui, Logger): custom_message_box(icon=QMessageBox.Warning, parent=None, title=_('Error'), - text=_('Cannot create window for wallet') + ':\n' + repr(e)) + text=_('Cannot load wallet') + '(2) :\n' + repr(e)) if app_is_starting: wallet_dir = os.path.dirname(path) path = os.path.join(wallet_dir, get_new_wallet_name(wallet_dir))