mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
change many str(e) to repr(e) as some exceptions were cryptic
it's often valuable to see the type of the exception (especially as for some exceptions str(e) == '')
This commit is contained in:
parent
40e2b1d6e7
commit
f60f690ca9
26 changed files with 48 additions and 48 deletions
|
@ -415,7 +415,7 @@ class Commands:
|
|||
addr = self.wallet.import_private_key(privkey, password)
|
||||
out = "Keypair imported: " + addr
|
||||
except Exception as e:
|
||||
out = "Error: " + str(e)
|
||||
out = "Error: " + repr(e)
|
||||
return out
|
||||
|
||||
def _resolver(self, x):
|
||||
|
|
|
@ -265,7 +265,7 @@ def query(url, rtype):
|
|||
out = get_and_validate(ns, url, rtype)
|
||||
validated = True
|
||||
except BaseException as e:
|
||||
_logger.info(f"DNSSEC error: {str(e)}")
|
||||
_logger.info(f"DNSSEC error: {repr(e)}")
|
||||
resolver = dns.resolver.get_default_resolver()
|
||||
out = resolver.query(url, rtype)
|
||||
validated = False
|
||||
|
|
|
@ -290,7 +290,7 @@ class SendScreen(CScreen):
|
|||
return
|
||||
except Exception as e:
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
self.app.show_error(str(e))
|
||||
self.app.show_error(repr(e))
|
||||
return
|
||||
if rbf:
|
||||
tx.set_rbf(True)
|
||||
|
@ -410,7 +410,7 @@ class ReceiveScreen(CScreen):
|
|||
self.app.wallet.add_payment_request(req, self.app.electrum_config)
|
||||
added_request = True
|
||||
except Exception as e:
|
||||
self.app.show_error(_('Error adding payment request') + ':\n' + str(e))
|
||||
self.app.show_error(_('Error adding payment request') + ':\n' + repr(e))
|
||||
added_request = False
|
||||
finally:
|
||||
self.app.update_tab('requests')
|
||||
|
|
|
@ -230,7 +230,7 @@ class ElectrumGui(Logger):
|
|||
custom_message_box(icon=QMessageBox.Warning,
|
||||
parent=None,
|
||||
title=_('Error'),
|
||||
text=_('Cannot load wallet') + ' (1):\n' + str(e))
|
||||
text=_('Cannot load wallet') + ' (1):\n' + repr(e))
|
||||
# if app is starting, still let wizard to appear
|
||||
if not app_is_starting:
|
||||
return
|
||||
|
@ -242,7 +242,7 @@ class ElectrumGui(Logger):
|
|||
custom_message_box(icon=QMessageBox.Warning,
|
||||
parent=None,
|
||||
title=_('Error'),
|
||||
text=_('Cannot load wallet') + ' (2):\n' + str(e))
|
||||
text=_('Cannot load wallet') + ' (2):\n' + repr(e))
|
||||
if not wallet:
|
||||
return
|
||||
# create or raise window
|
||||
|
@ -257,7 +257,7 @@ class ElectrumGui(Logger):
|
|||
custom_message_box(icon=QMessageBox.Warning,
|
||||
parent=None,
|
||||
title=_('Error'),
|
||||
text=_('Cannot create window for wallet') + ':\n' + str(e))
|
||||
text=_('Cannot create window for wallet') + ':\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))
|
||||
|
|
|
@ -99,4 +99,4 @@ class AddressDialog(WindowModalDialog):
|
|||
try:
|
||||
self.parent.show_qrcode(text, 'Address', parent=self)
|
||||
except Exception as e:
|
||||
self.show_message(str(e))
|
||||
self.show_message(repr(e))
|
||||
|
|
|
@ -265,7 +265,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||
continue
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
self.show_message(title=_('Error'), msg=str(e))
|
||||
self.show_message(title=_('Error'), msg=repr(e))
|
||||
raise UserCancelled()
|
||||
elif self.temp_storage.is_encrypted_with_hw_device():
|
||||
try:
|
||||
|
@ -278,7 +278,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||
return self.select_storage(path, get_wallet_from_daemon)
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
self.show_message(title=_('Error'), msg=str(e))
|
||||
self.show_message(title=_('Error'), msg=repr(e))
|
||||
raise UserCancelled()
|
||||
if self.temp_storage.is_past_initial_decryption():
|
||||
break
|
||||
|
|
|
@ -345,7 +345,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
self.logger.error("on_error", exc_info=exc_info)
|
||||
except OSError:
|
||||
pass # see #4418
|
||||
self.show_error(str(e))
|
||||
self.show_error(repr(e))
|
||||
|
||||
def on_network(self, event, *args):
|
||||
if event == 'wallet_updated':
|
||||
|
@ -1026,7 +1026,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
try:
|
||||
self.wallet.sign_payment_request(addr, alias, alias_addr, password)
|
||||
except Exception as e:
|
||||
self.show_error(str(e))
|
||||
self.show_error(repr(e))
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
@ -1045,7 +1045,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
self.wallet.add_payment_request(req, self.config)
|
||||
except Exception as e:
|
||||
self.logger.exception('Error adding payment request')
|
||||
self.show_error(_('Error adding payment request') + ':\n' + str(e))
|
||||
self.show_error(_('Error adding payment request') + ':\n' + repr(e))
|
||||
else:
|
||||
self.sign_payment_request(addr)
|
||||
self.save_request_button.setEnabled(False)
|
||||
|
@ -2151,7 +2151,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
return
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
self.show_error(str(e))
|
||||
self.show_error(repr(e))
|
||||
return
|
||||
old_password = hw_dev_pw if self.wallet.has_password() else None
|
||||
new_password = hw_dev_pw if encrypt_file else None
|
||||
|
@ -2288,7 +2288,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
seed = keystore.get_seed(password)
|
||||
passphrase = keystore.get_passphrase(password)
|
||||
except BaseException as e:
|
||||
self.show_error(str(e))
|
||||
self.show_error(repr(e))
|
||||
return
|
||||
from .seed_dialog import SeedDialog
|
||||
d = SeedDialog(self, seed, passphrase)
|
||||
|
@ -2308,7 +2308,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
pk, redeem_script = self.wallet.export_private_key(address, password)
|
||||
except Exception as e:
|
||||
self.logger.exception('')
|
||||
self.show_message(str(e))
|
||||
self.show_message(repr(e))
|
||||
return
|
||||
xtype = bitcoin.deserialize_privkey(pk)[0]
|
||||
d = WindowModalDialog(self, _("Private key"))
|
||||
|
@ -2502,7 +2502,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
tx = tx_from_str(txt)
|
||||
return Transaction(tx)
|
||||
except BaseException as e:
|
||||
self.show_critical(_("Electrum was unable to parse your transaction") + ":\n" + str(e))
|
||||
self.show_critical(_("Electrum was unable to parse your transaction") + ":\n" + repr(e))
|
||||
return
|
||||
|
||||
def read_tx_from_qrcode(self):
|
||||
|
@ -2510,7 +2510,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
try:
|
||||
data = qrscanner.scan_barcode(self.config.get_video_device())
|
||||
except BaseException as e:
|
||||
self.show_error(str(e))
|
||||
self.show_error(repr(e))
|
||||
return
|
||||
if not data:
|
||||
return
|
||||
|
@ -2563,7 +2563,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
raw_tx = self.network.run_from_another_thread(
|
||||
self.network.get_transaction(txid, timeout=10))
|
||||
except Exception as e:
|
||||
self.show_message(_("Error getting transaction from network") + ":\n" + str(e))
|
||||
self.show_message(_("Error getting transaction from network") + ":\n" + repr(e))
|
||||
return
|
||||
tx = transaction.Transaction(raw_tx)
|
||||
self.show_transaction(tx)
|
||||
|
@ -2655,7 +2655,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
self.show_critical(txt, title=_("Unable to create csv"))
|
||||
|
||||
except Exception as e:
|
||||
self.show_message(str(e))
|
||||
self.show_message(repr(e))
|
||||
return
|
||||
|
||||
self.show_message(_("Private keys exported."))
|
||||
|
@ -2732,7 +2732,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
try:
|
||||
valid_privkeys = get_pk(raise_on_error=True) is not None
|
||||
except Exception as e:
|
||||
button.setToolTip(f'{_("Error")}: {str(e)}')
|
||||
button.setToolTip(f'{_("Error")}: {repr(e)}')
|
||||
else:
|
||||
button.setToolTip('')
|
||||
button.setEnabled(get_address() is not None and valid_privkeys)
|
||||
|
@ -2753,7 +2753,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
try:
|
||||
coins, keypairs = sweep_preparations(get_pk(), self.network)
|
||||
except Exception as e: # FIXME too broad...
|
||||
self.show_message(str(e))
|
||||
self.show_message(repr(e))
|
||||
return
|
||||
self.do_clear()
|
||||
self.tx_external_keypairs = keypairs
|
||||
|
@ -2946,7 +2946,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
SSL_error = None
|
||||
except BaseException as e:
|
||||
SSL_identity = "error"
|
||||
SSL_error = str(e)
|
||||
SSL_error = repr(e)
|
||||
else:
|
||||
SSL_identity = ""
|
||||
SSL_error = None
|
||||
|
|
|
@ -49,7 +49,7 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
|
|||
with open(fileName, "r") as f:
|
||||
data = f.read()
|
||||
except BaseException as e:
|
||||
self.show_error(_('Error opening file') + ':\n' + str(e))
|
||||
self.show_error(_('Error opening file') + ':\n' + repr(e))
|
||||
else:
|
||||
self.setText(data)
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
|
|||
try:
|
||||
data = qrscanner.scan_barcode(get_config().get_video_device())
|
||||
except BaseException as e:
|
||||
self.show_error(str(e))
|
||||
self.show_error(repr(e))
|
||||
data = ''
|
||||
if not data:
|
||||
data = ''
|
||||
|
|
|
@ -191,7 +191,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
|||
self.show_error(_('Failed to display QR code.') + '\n' +
|
||||
_('Transaction is too large in size.'))
|
||||
except Exception as e:
|
||||
self.show_error(_('Failed to display QR code.') + '\n' + str(e))
|
||||
self.show_error(_('Failed to display QR code.') + '\n' + repr(e))
|
||||
|
||||
def sign(self):
|
||||
def sign_done(success):
|
||||
|
|
|
@ -199,7 +199,7 @@ class ElectrumGui:
|
|||
tx = self.wallet.mktx([TxOutput(TYPE_ADDRESS, self.str_recipient, amount)],
|
||||
password, self.config, fee)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
print(repr(e))
|
||||
return
|
||||
|
||||
if self.str_description:
|
||||
|
|
|
@ -362,7 +362,7 @@ class ElectrumGui:
|
|||
tx = self.wallet.mktx([TxOutput(TYPE_ADDRESS, self.str_recipient, amount)],
|
||||
password, self.config, fee)
|
||||
except Exception as e:
|
||||
self.show_message(str(e))
|
||||
self.show_message(repr(e))
|
||||
return
|
||||
|
||||
if self.str_description:
|
||||
|
|
|
@ -68,10 +68,10 @@ class VerifyingJSONRPCServer(SimpleJSONRPCServer, Logger):
|
|||
return True
|
||||
except (RPCAuthCredentialsInvalid, RPCAuthCredentialsMissing,
|
||||
RPCAuthUnsupportedType) as e:
|
||||
myself.send_error(401, str(e))
|
||||
myself.send_error(401, repr(e))
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
myself.send_error(500, str(e))
|
||||
myself.send_error(500, repr(e))
|
||||
return False
|
||||
|
||||
SimpleJSONRPCServer.__init__(
|
||||
|
|
|
@ -606,7 +606,7 @@ class DeviceMgr(ThreadJob):
|
|||
new_devices = f()
|
||||
except BaseException as e:
|
||||
self.logger.error('custom device enum failed. func {}, error {}'
|
||||
.format(str(f), str(e)))
|
||||
.format(str(f), repr(e)))
|
||||
else:
|
||||
devices.extend(new_devices)
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ class Plugin(BasePlugin):
|
|||
e = exc_info[1]
|
||||
try: self.logger.error("on_failure", exc_info=exc_info)
|
||||
except OSError: pass
|
||||
window.show_error(_("Failed to send transaction to cosigning pool") + ':\n' + str(e))
|
||||
window.show_error(_("Failed to send transaction to cosigning pool") + ':\n' + repr(e))
|
||||
|
||||
for window, xpub, K, _hash in self.cosigner_list:
|
||||
if not self.cosigner_can_sign(tx, xpub):
|
||||
|
@ -226,7 +226,7 @@ class Plugin(BasePlugin):
|
|||
message = bh2u(privkey.decrypt_message(message))
|
||||
except Exception as e:
|
||||
self.logger.exception('')
|
||||
window.show_error(_('Error decrypting message') + ':\n' + str(e))
|
||||
window.show_error(_('Error decrypting message') + ':\n' + repr(e))
|
||||
return
|
||||
|
||||
self.listener.clear(keyhash)
|
||||
|
|
|
@ -196,7 +196,7 @@ class Plugin(BasePlugin):
|
|||
self.processor.send(recipient, message, payload)
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
window.show_message(str(e))
|
||||
window.show_message(repr(e))
|
||||
else:
|
||||
window.show_message(_('Request sent.'))
|
||||
|
||||
|
@ -269,4 +269,4 @@ class CheckConnectionThread(QThread):
|
|||
conn = imaplib.IMAP4_SSL(self.server)
|
||||
conn.login(self.username, self.password)
|
||||
except BaseException as e:
|
||||
self.connection_error_signal.emit(str(e))
|
||||
self.connection_error_signal.emit(repr(e))
|
||||
|
|
|
@ -106,6 +106,6 @@ class Plugin(BasePlugin):
|
|||
d.show_warning(_('{} is not covered by GreenAddress instant confirmation').format(tx.txid()), title=_('Verification failed!'))
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
d.show_error(str(e))
|
||||
d.show_error(repr(e))
|
||||
finally:
|
||||
d.verify_button.setText(self.button_label)
|
||||
|
|
|
@ -216,7 +216,7 @@ class KeepKeyPlugin(HW_PluginBase):
|
|||
exit_code = 1
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
handler.show_error(str(e))
|
||||
handler.show_error(repr(e))
|
||||
exit_code = 1
|
||||
finally:
|
||||
wizard.loop.exit(exit_code)
|
||||
|
|
|
@ -160,7 +160,7 @@ class LabelsPlugin(BasePlugin):
|
|||
try:
|
||||
await self.pull_thread(wallet, force)
|
||||
except ErrorConnectingServer as e:
|
||||
self.logger.info(str(e))
|
||||
self.logger.info(repr(e))
|
||||
|
||||
def pull(self, wallet, force):
|
||||
if not wallet.network: raise Exception(_('You are offline.'))
|
||||
|
|
|
@ -60,7 +60,7 @@ class Ledger_Handler(QtHandlerBase):
|
|||
try:
|
||||
from .auth2fa import LedgerAuthDialog
|
||||
except ImportError as e:
|
||||
self.message_dialog(str(e))
|
||||
self.message_dialog(repr(e))
|
||||
return
|
||||
dialog = LedgerAuthDialog(self, data)
|
||||
dialog.exec_()
|
||||
|
|
|
@ -200,7 +200,7 @@ class SafeTPlugin(HW_PluginBase):
|
|||
exit_code = 1
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
handler.show_error(str(e))
|
||||
handler.show_error(repr(e))
|
||||
exit_code = 1
|
||||
finally:
|
||||
wizard.loop.exit(exit_code)
|
||||
|
|
|
@ -222,7 +222,7 @@ class TrezorPlugin(HW_PluginBase):
|
|||
exit_code = 1
|
||||
except BaseException as e:
|
||||
self.logger.exception('')
|
||||
handler.show_error(str(e))
|
||||
handler.show_error(repr(e))
|
||||
exit_code = 1
|
||||
finally:
|
||||
wizard.loop.exit(exit_code)
|
||||
|
|
|
@ -74,7 +74,7 @@ class Plugin(TrustedCoinPlugin):
|
|||
|
||||
def accept_terms_of_use(self, wizard):
|
||||
def handle_error(msg, e):
|
||||
wizard.show_error(msg + ':\n' + str(e))
|
||||
wizard.show_error(msg + ':\n' + repr(e))
|
||||
wizard.terminate()
|
||||
try:
|
||||
tos = server.get_terms_of_service()
|
||||
|
|
|
@ -132,7 +132,7 @@ class Plugin(TrustedCoinPlugin):
|
|||
e = exc_info[1]
|
||||
window.show_error("{header}\n{exc}\n\n{tor}"
|
||||
.format(header=_('Error getting TrustedCoin account info.'),
|
||||
exc=str(e),
|
||||
exc=repr(e),
|
||||
tor=_('If you keep experiencing network problems, try using a Tor proxy.')))
|
||||
return WaitingDialog(parent=window,
|
||||
message=_('Requesting account info from TrustedCoin server...'),
|
||||
|
@ -253,7 +253,7 @@ class Plugin(TrustedCoinPlugin):
|
|||
except Exception as e:
|
||||
self.logger.exception('Could not retrieve Terms of Service')
|
||||
tos_e.error_signal.emit(_('Could not retrieve Terms of Service:')
|
||||
+ '\n' + str(e))
|
||||
+ '\n' + repr(e))
|
||||
return
|
||||
self.TOS = tos
|
||||
tos_e.tos_signal.emit()
|
||||
|
|
|
@ -485,7 +485,7 @@ class TrustedCoinPlugin(BasePlugin):
|
|||
billing_info = server.get(wallet.get_user_id()[1])
|
||||
except ErrorConnectingServer as e:
|
||||
if suppress_connection_error:
|
||||
self.logger.info(str(e))
|
||||
self.logger.info(repr(e))
|
||||
return
|
||||
raise
|
||||
billing_index = billing_info['billing_index']
|
||||
|
@ -709,7 +709,7 @@ class TrustedCoinPlugin(BasePlugin):
|
|||
wizard.show_message(str(e))
|
||||
wizard.terminate()
|
||||
except Exception as e:
|
||||
wizard.show_message(str(e))
|
||||
wizard.show_message(repr(e))
|
||||
wizard.terminate()
|
||||
else:
|
||||
k3 = keystore.from_xpub(xpub3)
|
||||
|
|
|
@ -292,6 +292,6 @@ class Notifier(SynchronizerBase):
|
|||
async with session.post(url, json=data, headers=headers) as resp:
|
||||
await resp.text()
|
||||
except Exception as e:
|
||||
self.logger.info(str(e))
|
||||
self.logger.info(repr(e))
|
||||
else:
|
||||
self.logger.info(f'Got Response for {addr}')
|
||||
|
|
|
@ -121,7 +121,7 @@ class SPV(NetworkJobOnDefaultServer):
|
|||
if self.network.config.get("skipmerklecheck"):
|
||||
self.logger.info(f"skipping merkle proof check {tx_hash}")
|
||||
else:
|
||||
self.logger.info(str(e))
|
||||
self.logger.info(repr(e))
|
||||
raise GracefulDisconnect(e)
|
||||
# we passed all the tests
|
||||
self.merkle_roots[tx_hash] = header.get('merkle_root')
|
||||
|
|
Loading…
Add table
Reference in a new issue