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 <lambda>
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())
```
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user