Allow custom handling of python Dumper warnings/exceptions

Change-Id: I04108a09c317675d597bb6d0d58331c70ce02fb9
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Tor Arne Vestbø
2017-05-15 16:14:58 +02:00
parent 6754514489
commit 5bc796094a
2 changed files with 17 additions and 18 deletions
+17 -12
View File
@@ -152,27 +152,18 @@ class ReportItem:
def warn(message):
print('bridgemessage={msg="%s"},' % message.replace('"', '$').encode('latin1'))
DumperBase.warn(message)
def xwarn(message):
print('bridgemessage={msg="%s"},' % message.replace('"', '$').encode('latin1'))
warn(message)
import traceback
traceback.print_stack()
def error(message):
raise RuntimeError(message)
def showException(msg, exType, exValue, exTraceback):
warn('**** CAUGHT EXCEPTION: %s ****' % msg)
try:
import traceback
for line in traceback.format_exception(exType, exValue, exTraceback):
warn('%s' % line)
except:
pass
DumperBase.showException(msg, exType, exValue, exTraceback)
class Children:
def __init__(self, d, numChild = 1, childType = None, childNumChild = None,
@@ -248,6 +239,20 @@ class UnnamedSubItem(SubItem):
self.name = None
class DumperBase:
@staticmethod
def warn(message):
print('bridgemessage={msg="%s"},' % message.replace('"', '$').encode('latin1'))
@staticmethod
def showException(msg, exType, exValue, exTraceback):
warn('**** CAUGHT EXCEPTION: %s ****' % msg)
try:
import traceback
for line in traceback.format_exception(exType, exValue, exTraceback):
warn('%s' % line)
except:
pass
def __init__(self):
self.isCdb = False
self.isGdb = False