commit e68b6447cc3457b5151c148873fbd82b8d0a1f49
parent 2d3c2eeea9c225af2ec2d1654363c4b75c5b1158
Author: SomberNight <somber.night@protonmail.com>
Date: Wed, 1 Apr 2020 14:24:29 +0200
hww: catch exceptions when user clicks on hww qt status bar icon
E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
File "...\electrum\electrum\plugins\ledger\ledger.py", line 167, in perform_hw1_preflight
firmwareInfo = self.dongleObject.getFirmwareVersion()
File "...\Python38\site-packages\btchip\btchip.py", line 561, in getFirmwareVersion
response = self.dongle.exchange(bytearray(apdu))
File "...\Python38\site-packages\btchip\btchipComm.py", line 127, in exchange
raise BTChipException("Invalid status %04x" % sw, sw)
btchip.btchipException.BTChipException: Exception : Invalid status 6faa
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "...\electrum\electrum\gui\qt\main_window.py", line 120, in onPress
self.func()
File "...\electrum\electrum\plugins\hw_wallet\qt.py", line 260, in show_settings_dialog
device_id = self.choose_device(window, keystore)
File "...\electrum\electrum\plugins\hw_wallet\qt.py", line 253, in choose_device
info = self.device_manager().select_device(self, keystore.handler, keystore)
File "...\electrum\electrum\plugin.py", line 554, in select_device
infos = self.unpaired_device_infos(handler, plugin, devices)
File "...\electrum\electrum\plugin.py", line 545, in unpaired_device_infos
soft_device_id=client.get_soft_device_id()))
File "...\electrum\electrum\plugins\ledger\ledger.py", line 88, in get_soft_device_id
self._soft_device_id = self.request_root_fingerprint_from_device()
File "...\electrum\electrum\plugins\hw_wallet\plugin.py", line 197, in request_root_fingerprint_from_device
child_of_root_xpub = self.get_xpub("m/0'", xtype='standard')
File "...\electrum\electrum\plugins\ledger\ledger.py", line 55, in catch_exception
return func(self, *args, **kwargs)
File "...\electrum\electrum\plugins\ledger\ledger.py", line 103, in get_xpub
self.checkDevice()
File "...\electrum\electrum\plugins\ledger\ledger.py", line 210, in checkDevice
self.perform_hw1_preflight()
File "...\electrum\electrum\plugins\ledger\ledger.py", line 198, in perform_hw1_preflight
raise UserFacingException("Dongle is temporarily locked - please unplug it and replug it again")
electrum.util.UserFacingException: Dongle is temporarily locked - please unplug it and replug it again
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -379,6 +379,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
elif isinstance(e, UserFacingException):
self.show_error(str(e))
else:
+ # TODO would be nice if we just sent these to the crash reporter...
+ # anything we don't want to send there, we should explicitly catch
+ # send_exception_to_crash_reporter(e)
try:
self.logger.error("on_error", exc_info=exc_info)
except OSError:
diff --git a/electrum/plugins/hw_wallet/qt.py b/electrum/plugins/hw_wallet/qt.py
@@ -39,7 +39,7 @@ from electrum.gui.qt.installwizard import InstallWizard
from electrum.i18n import _
from electrum.logging import Logger
-from electrum.util import parse_URI, InvalidBitcoinURI, UserCancelled
+from electrum.util import parse_URI, InvalidBitcoinURI, UserCancelled, UserFacingException
from electrum.plugin import hook, DeviceUnpairableError
from .plugin import OutdatedHwFirmwareException, HW_PluginBase, HardwareHandlerBase
@@ -213,7 +213,7 @@ class QtPluginBase(object):
window.show_error(message)
return
tooltip = self.device + '\n' + (keystore.label or 'unnamed')
- cb = partial(self.show_settings_dialog, window, keystore)
+ cb = partial(self._on_status_bar_button_click, window=window, keystore=keystore)
button = StatusBarButton(read_QIcon(self.icon_unpaired), tooltip, cb)
button.icon_paired = self.icon_paired
button.icon_unpaired = self.icon_unpaired
@@ -226,6 +226,13 @@ class QtPluginBase(object):
# Trigger a pairing
keystore.thread.add(partial(self.get_client, keystore))
+ def _on_status_bar_button_click(self, *, window: ElectrumWindow, keystore: 'Hardware_KeyStore'):
+ try:
+ self.show_settings_dialog(window=window, keystore=keystore)
+ except (UserFacingException, UserCancelled) as e:
+ exc_info = (type(e), e, e.__traceback__)
+ self.on_task_thread_error(window=window, keystore=keystore, exc_info=exc_info)
+
def on_task_thread_error(self: Union['QtPluginBase', HW_PluginBase], window: ElectrumWindow,
keystore: 'Hardware_KeyStore', exc_info):
e = exc_info[1]