Skip to content

Commit

Permalink
Split exception description from exception traceback
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jkonecny12 committed Oct 15, 2015
1 parent bf39215 commit e8550bf
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pyanaconda/exception.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e8550bf

Please sign in to comment.