don't print out expected Exception

This commit is contained in:
KIU Shueng Chuan 2021-05-13 13:55:09 +08:00
parent eed220e874
commit 210203d628

View File

@ -323,7 +323,7 @@ class RemoteEventHandler(object):
self.send(request='result', reqId=reqId, callSync='off', opts=dict(result=result)) self.send(request='result', reqId=reqId, callSync='off', opts=dict(result=result))
def replyError(self, reqId, *exc): def replyError(self, reqId, *exc):
print("error: %s %s %s" % (self.name, str(reqId), str(exc[1]))) # print("error: %s %s %s" % (self.name, str(reqId), str(exc[1])))
excStr = traceback.format_exception(*exc) excStr = traceback.format_exception(*exc)
try: try:
self.send(request='error', reqId=reqId, callSync='off', opts=dict(exception=exc[1], excString=excStr)) self.send(request='error', reqId=reqId, callSync='off', opts=dict(exception=exc[1], excString=excStr))
@ -503,9 +503,12 @@ class RemoteEventHandler(object):
#print ''.join(result) #print ''.join(result)
exc, excStr = result exc, excStr = result
if exc is not None: if exc is not None:
warnings.warn("===== Remote process raised exception on request: =====", RemoteExceptionWarning) # PySide6 6.1.0 does an attribute lookup for feature testing
warnings.warn(''.join(excStr), RemoteExceptionWarning) # in such a case, failure is normal
warnings.warn("===== Local Traceback to request follows: =====", RemoteExceptionWarning) if excStr[-1] not in ["AttributeError: 'function' object has no attribute 'im_func'\n"]:
warnings.warn("===== Remote process raised exception on request: =====", RemoteExceptionWarning)
warnings.warn(''.join(excStr), RemoteExceptionWarning)
warnings.warn("===== Local Traceback to request follows: =====", RemoteExceptionWarning)
raise exc raise exc
else: else:
print(''.join(excStr)) print(''.join(excStr))