From 8edf442785c436a9dafef815486985448da83386 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 15 Jan 2009 14:34:04 +0100 Subject: [PATCH] [IMP] When a error occur in a report, the good stacktrace is sent to the client bzr revid: christophe@tinyerp.com-20090115133404-mcmgvua5jqwo4uj7 --- bin/netsvc.py | 5 ++++- bin/service/web_services.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/netsvc.py b/bin/netsvc.py index b0e5035e29f..745921023e3 100644 --- a/bin/netsvc.py +++ b/bin/netsvc.py @@ -228,7 +228,10 @@ class OpenERPDispatcher: return result except Exception, e: self.log('exception', tools.exception_to_unicode(e)) - tb = sys.exc_info() + if hasattr(e, 'traceback'): + tb = e.traceback + else: + tb = sys.exc_info() tb_s = "".join(traceback.format_exception(*tb)) if tools.config['debug_mode']: import pdb diff --git a/bin/service/web_services.py b/bin/service/web_services.py index 7b4b5c35156..ab13bae4451 100644 --- a/bin/service/web_services.py +++ b/bin/service/web_services.py @@ -518,6 +518,13 @@ wizard() # Report state: # False -> True # + +class ExceptionWithTraceback(Exception): + def __init__(self, msg, tb): + self.message = msg + self.traceback = tb + self.args = (msg, tb) + class report_spool(netsvc.Service): def __init__(self, name='report'): netsvc.Service.__init__(self, name) @@ -553,12 +560,12 @@ class report_spool(netsvc.Service): except Exception, exception: import traceback import sys - tb_s = reduce(lambda x, y: x+y, traceback.format_exception( - sys.exc_type, sys.exc_value, sys.exc_traceback)) + tb = sys.exc_info() + tb_s = "".join(traceback.format_exception(*tb)) logger = netsvc.Logger() logger.notifyChannel('web-services', netsvc.LOG_ERROR, 'Exception: %s\n%s' % (str(exception), tb_s)) - self._reports[id]['exception'] = exception + self._reports[id]['exception'] = ExceptionWithTraceback(tools.exception_to_unicode(exception), tb) self._reports[id]['state'] = True cr.close() return True