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

jkonecny12 installerbot-noreply at redhat.com
Thu Oct 15 09:07:33 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).
---
 pyanaconda/exception.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index e698b42..d9a5a31 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -50,6 +50,25 @@
 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:
+            return traceback.format_exception_only(self.type, self.value)[0].split("\nTraceback")[0].strip()
+        else:
+            return ""
+
 class AnacondaExceptionHandler(ExceptionHandler):
 
     def __init__(self, confObj, intfClass, exnClass, tty_num, gui_lock, interactive):
@@ -273,7 +292,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/e8550bfef5c0eb301b698cbe8738eb59779169eb


More information about the anaconda-patches mailing list