Home | Trees | Indices | Help |
|
---|
|
1 # ============================================================================ 2 # 3 # Copyright (C) 2007-2008 Conceptive Engineering bvba. All rights reserved. 4 # www.conceptive.be / project-camelot@conceptive.be 5 # 6 # This file is part of the Camelot Library. 7 # 8 # This file may be used under the terms of the GNU General Public 9 # License version 2.0 as published by the Free Software Foundation 10 # and appearing in the file LICENSE.GPL included in the packaging of 11 # this file. Please review the following information to ensure GNU 12 # General Public Licensing requirements will be met: 13 # http://www.trolltech.com/products/qt/opensource.html 14 # 15 # If you are unsure which license is appropriate for your use, please 16 # review the following information: 17 # http://www.trolltech.com/products/qt/licensing.html or contact 18 # project-camelot@conceptive.be. 19 # 20 # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 21 # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 # 23 # For use of this library in commercial applications, please contact 24 # project-camelot@conceptive.be 25 # 26 # ============================================================================ 27 28 """Functions and widget to represent exceptions to the user""" 29 30 from camelot.core.utils import ugettext as _ 3133 """Log an exception 34 :exception_info: exception information in a user readable format, to be used when 35 displaying an exception message box""" 36 logger.error( text, exc_info = exception ) 37 import traceback, cStringIO 38 sio = cStringIO.StringIO() 39 traceback.print_exc(file=sio) 40 traceback_print = sio.getvalue() 41 sio.close() 42 return (exception, traceback_print)4345 """Display an exception that occurred in the model thread in a message box, 46 use this function as the exception argument in the model thread's post function 47 to represent the exception to the user 48 49 :param exception_info: a tuple containing the exception that was thrown and the 50 model thread in which the exception was thrown 51 """ 52 from PyQt4 import QtGui 53 title = title or _('Exception') 54 text = text or _('An unexpected event occurred') 55 exc, traceback = exception_info 56 msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 57 unicode(title), unicode(text)) 58 # chop the size of the text to prevent error dialogs larger than the screen 59 msgBox.setInformativeText(unicode(exc)[:1000]) 60 msgBox.setDetailedText(traceback) 61 msgBox.exec_()62
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 12 15:42:13 2010 | http://epydoc.sourceforge.net |