[master 2/2] Split exception description from exception traceback

jkonecny12 installerbot-noreply at redhat.com
Fri Oct 16 12:20:32 UTC 2015


From: Jiri Konecny <jkonecny at redhat.com>

When traceback will be part of the exception message split the
description from traceback. Description is used in name of the
bug in Bugzilla.
This is useful when saving exception in exception handler and
raising this exception elsewhere (subprocess exception).

This is based on patch from BlivetGUI. Thank you Vojtech Trefny.
---
 pyanaconda/exception.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index e698b42..58d2c1f 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -50,6 +50,26 @@
 import logging
 log = logging.getLogger("anaconda")
 
+class AnacondaReverseExceptionDump(ReverseExceptionDump):
+
+    @property
+    def desc(self):
+        """
+        When traceback will be part of the exception message split the
+        description from traceback. Description is used in name of the
+        bug in Bugzilla.
+        This is useful when saving exception in exception handler and
+        raising this exception elsewhere (subprocess exception).
+
+        :return: Exception description (bug name)
+        :rtype: str
+        """
+        if self.type and self.value:
+            (description, _exc_traceback) = traceback.format_exception_only(self.type, self.value)[0].split("\nTraceback")
+            return description.strip()
+        else:
+            return ""
+
 class AnacondaExceptionHandler(ExceptionHandler):
 
     def __init__(self, confObj, intfClass, exnClass, tty_num, gui_lock, interactive):
@@ -273,7 +293,7 @@ def initExceptionHandling(anaconda):
 
     interactive = not anaconda.displayMode == 'c'
     handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
-                                       ReverseExceptionDump, anaconda.intf.tty_num,
+                                       AnacondaReverseExceptionDump, anaconda.intf.tty_num,
                                        anaconda.gui_initialized, interactive)
     handler.install(anaconda)
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/7ad08ac1f11b2a2338608dcff80fed32fe3fca12


More information about the anaconda-patches mailing list