Changeset 79138 in vbox for trunk/src/VBox/ValidationKit/testdriver/reporter.py
- Timestamp:
- Jun 14, 2019 1:00:00 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/reporter.py
r79087 r79138 1072 1072 # 1073 1073 1074 g_fnComXcptFormatter = None; 1075 1076 def setComXcptFormatter(fnCallback): 1077 """ 1078 Install callback for prettier COM exception formatting. 1079 1080 The callback replaces the work done by format_exception_only() and 1081 takes the same arguments. It returns None if not interested in the 1082 exception. 1083 """ 1084 global g_fnComXcptFormatter; 1085 g_fnComXcptFormatter = fnCallback; 1086 return True; 1087 1088 def formatExceptionOnly(oType, oXcpt, sCaller, sTsPrf): 1089 """ 1090 Wrapper around traceback.format_exception_only and __g_fnComXcptFormatter. 1091 """ 1092 #asRet = ['oType=%s type(oXcpt)=%s' % (oType, type(oXcpt),)]; 1093 asRet = []; 1094 1095 # Try the callback first. 1096 fnCallback = g_fnComXcptFormatter; 1097 if fnCallback: 1098 try: 1099 asRetCb = fnCallback(oType, oXcpt); 1100 if asRetCb: 1101 return asRetCb; 1102 #asRet += asRetCb; 1103 except: 1104 g_oReporter.log(0, '** internal-error: Hit exception #2 in __g_fnComXcptFormatter! %s' 1105 % (traceback.format_exc()), sCaller, sTsPrf); 1106 asRet += ['internal error: exception in __g_fnComXcptFormatter']; 1107 1108 # Now try format_exception_only: 1109 try: 1110 asRet += traceback.format_exception_only(oType, oXcpt); 1111 except: 1112 g_oReporter.log(0, '** internal-error: Hit exception #2 in format_exception_only! %s' 1113 % (traceback.format_exc()), sCaller, sTsPrf); 1114 asRet += ['internal error: Exception in format_exception_only!']; 1115 return asRet; 1116 1117 1074 1118 def logXcptWorker(iLevel, fIncErrors, sPrefix="", sText=None, cFrames=1): 1075 1119 """ … … 1099 1143 if sText is not None: 1100 1144 rc = g_oReporter.log(iLevel, "%s%s" % (sPrefix, sText), sCaller, sTsPrf); 1101 asInfo = [];1145 asInfo = None; 1102 1146 try: 1103 asInfo = asInfo + traceback.format_exception_only(oType, oValue);1147 asInfo = formatExceptionOnly(oType, oValue, sCaller, sTsPrf); 1104 1148 if cFrames is not None and cFrames <= 1: 1105 1149 asInfo = asInfo + traceback.format_tb(oTraceback, 1); … … 1133 1177 g_oLock.release(); 1134 1178 return rc; 1179 1135 1180 1136 1181 # … … 1589 1634 if oType is not None: 1590 1635 sCaller = utils.getCallerName(oTraceback.tb_frame); 1591 sXcpt = ' '.join( traceback.format_exception_only(oType, oValue));1636 sXcpt = ' '.join(formatExceptionOnly(oType, oValue, sCaller, utils.getTimePrefix())); 1592 1637 else: 1593 1638 sCaller = utils.getCallerName();
Note:
See TracChangeset
for help on using the changeset viewer.