plugins: hardware: HardwareHandlerBase.show_error() takes str, not exc
This is just a minor conceptual clean-up, runtime behaviour is not being changed, as ultimately, much later in the exec flow, the msg object being passed around is cast to str already. (e.g. see str(text) at https://github.com/spesmilo/electrum/blob/4f7b6e897710338e8a4cfb8fa97c305218bdff88/electrum/gui/qt/util.py#L375-L379)
This commit is contained in:
@@ -577,10 +577,10 @@ class BitBox02_KeyStore(Hardware_KeyStore):
|
||||
super().__init__(d)
|
||||
self.ux_busy = False
|
||||
|
||||
def give_error(self, message: Exception):
|
||||
def give_error(self, message: str | BaseException):
|
||||
self.logger.info(message)
|
||||
if not self.ux_busy:
|
||||
self.handler.show_error(message)
|
||||
self.handler.show_error(str(message))
|
||||
else:
|
||||
self.ux_busy = False
|
||||
raise UserFacingException(message)
|
||||
@@ -636,7 +636,7 @@ class BitBox02_KeyStore(Hardware_KeyStore):
|
||||
self.handler.finished()
|
||||
except Exception as e:
|
||||
self.logger.exception("")
|
||||
self.handler.show_error(e)
|
||||
self.handler.show_error(str(e))
|
||||
|
||||
|
||||
class BitBox02Plugin(HW_PluginBase):
|
||||
|
||||
@@ -301,10 +301,10 @@ class Coldcard_KeyStore(Hardware_KeyStore):
|
||||
|
||||
return client
|
||||
|
||||
def give_error(self, message):
|
||||
def give_error(self, message: str | BaseException):
|
||||
self.logger.info(message)
|
||||
if not self.ux_busy:
|
||||
self.handler.show_error(message)
|
||||
self.handler.show_error(str(message))
|
||||
else:
|
||||
self.ux_busy = False
|
||||
raise UserFacingException(message)
|
||||
@@ -460,7 +460,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
|
||||
_('Error showing address') + ':', str(exc)))
|
||||
except BaseException as exc:
|
||||
self.logger.exception('')
|
||||
self.handler.show_error(exc)
|
||||
self.handler.show_error(str(exc))
|
||||
|
||||
@wrap_busy
|
||||
def show_p2sh_address(self, M, script, xfp_paths, txin_type):
|
||||
@@ -482,7 +482,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
|
||||
str(exc)))
|
||||
except BaseException as exc:
|
||||
self.logger.exception('')
|
||||
self.handler.show_error(exc)
|
||||
self.handler.show_error(str(exc))
|
||||
|
||||
|
||||
class ColdcardPlugin(HW_PluginBase):
|
||||
|
||||
@@ -454,7 +454,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
|
||||
Hardware_KeyStore.__init__(self, d)
|
||||
self.maxInputs = 14 # maximum inputs per single sign command
|
||||
|
||||
def give_error(self, message):
|
||||
def give_error(self, message: str | BaseException):
|
||||
raise Exception(message)
|
||||
|
||||
def decrypt_message(self, pubkey, message, password):
|
||||
|
||||
@@ -403,10 +403,10 @@ class Ledger_Client_Legacy(Ledger_Client):
|
||||
self.signing = False
|
||||
return wrapper
|
||||
|
||||
def give_error(self, message):
|
||||
def give_error(self, message: str | BaseException):
|
||||
_logger.info(message)
|
||||
if not self.signing:
|
||||
self.handler.show_error(message)
|
||||
self.handler.show_error(str(message))
|
||||
else:
|
||||
self.signing = False
|
||||
raise UserFacingException(message)
|
||||
@@ -545,10 +545,10 @@ class Ledger_Client_Legacy(Ledger_Client):
|
||||
_('Your device might not have support for this functionality.')))
|
||||
else:
|
||||
_logger.exception('')
|
||||
self.handler.show_error(e)
|
||||
self.handler.show_error(str(e))
|
||||
except BaseException as e:
|
||||
_logger.exception('')
|
||||
self.handler.show_error(e)
|
||||
self.handler.show_error(str(e))
|
||||
finally:
|
||||
self.handler.finished()
|
||||
|
||||
@@ -959,7 +959,7 @@ class Ledger_Client_New(Ledger_Client):
|
||||
pass # cancelled by user
|
||||
except BaseException as e:
|
||||
_logger.exception('Error while showing an address')
|
||||
self.handler.show_error(e)
|
||||
self.handler.show_error(str(e))
|
||||
finally:
|
||||
self.handler.finished()
|
||||
|
||||
@@ -1139,7 +1139,7 @@ class Ledger_Client_New(Ledger_Client):
|
||||
pass # cancelled by user
|
||||
except BaseException as e:
|
||||
_logger.exception('Error while signing')
|
||||
self.handler.show_error(e)
|
||||
self.handler.show_error(str(e))
|
||||
finally:
|
||||
self.handler.finished()
|
||||
|
||||
@@ -1166,7 +1166,7 @@ class Ledger_Client_New(Ledger_Client):
|
||||
pass # cancelled by user
|
||||
except BaseException as e:
|
||||
_logger.exception('')
|
||||
self.handler.show_error(e)
|
||||
self.handler.show_error(str(e))
|
||||
finally:
|
||||
self.handler.finished()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user