diff --git a/electrum/base_crash_reporter.py b/electrum/base_crash_reporter.py index 10339333d..ea77a3d37 100644 --- a/electrum/base_crash_reporter.py +++ b/electrum/base_crash_reporter.py @@ -81,7 +81,7 @@ class BaseCrashReporter(Logger): def get_traceback_info(self): exc_string = str(self.exc_args[1]) stack = traceback.extract_tb(self.exc_args[2]) - readable_trace = "".join(traceback.format_list(stack)) + readable_trace = self.__get_traceback_str_to_send() id = { "file": stack[-1].filename, "name": stack[-1].name, @@ -109,12 +109,19 @@ class BaseCrashReporter(Logger): pass return args - def _get_traceback_str(self) -> str: + def __get_traceback_str_to_send(self) -> str: + # make sure that traceback sent to crash reporter contains + # e.__context__ and e.__cause__, i.e. if there was a chain of + # exceptions, we want the full traceback for the whole chain. return "".join(traceback.format_exception(*self.exc_args)) + def _get_traceback_str_to_display(self) -> str: + # overridden in Qt subclass + return self.__get_traceback_str_to_send() + def get_report_string(self): info = self.get_additional_info() - info["traceback"] = self._get_traceback_str() + info["traceback"] = self._get_traceback_str_to_display() return self.issue_template.format(**info) def get_user_description(self): diff --git a/electrum/gui/qt/exception_window.py b/electrum/gui/qt/exception_window.py index 7712eb4ca..a33574055 100644 --- a/electrum/gui/qt/exception_window.py +++ b/electrum/gui/qt/exception_window.py @@ -145,11 +145,11 @@ class Exception_Window(BaseCrashReporter, QWidget, MessageBoxMixin, Logger): wallet_types = Exception_Hook._INSTANCE.wallet_types_seen return ",".join(wallet_types) - def _get_traceback_str(self) -> str: + def _get_traceback_str_to_display(self) -> str: # The msg_box that shows the report uses rich_text=True, so # if traceback contains special HTML characters, e.g. '<', # they need to be escaped to avoid formatting issues. - traceback_str = super()._get_traceback_str() + traceback_str = super()._get_traceback_str_to_display() return html.escape(traceback_str)