def display_exception_message(exception, lessonfile=None):
"""Call this function only inside an except clause."""
sourcefile, lineno, func, code = traceback.extract_tb(sys.exc_info()[2])[0]
# We can replace characters because we will only display the
# file name, not open the file.
sourcefile = sourcefile.decode(sys.getfilesystemencoding(), 'replace')
m = ExceptionDialog(exception)
if lessonfile:
m.add_text(_("Please check the lesson file %s.") % lessonfile)
if sourcefile:
m.add_text(_('The exception was caught in\n"%(filename)s", line %(lineno)i.') % {'filename': sourcefile, 'lineno': lineno})
if 'm_nonwrapped_text' in dir(exception):
m.add_nonwrapped_text(exception.m_nonwrapped_text)
m.run()
m.destroy()
评论列表
文章目录