Commit a1f53d83 authored by Vincent Pelletier's avatar Vincent Pelletier

Store exception information in native format inside message. Factorises...

Store exception information in native format inside message. Factorises sys.exc_info calls and exception rendering code.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19169 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6d8060d6
......@@ -331,8 +331,9 @@ class SQLDict(RAMDict, SQLBase):
if m.active_process:
message_with_active_process_list.append(m)
else:
if type(m.exc_type) is ClassType and \
issubclass(m.exc_type, ConflictError):
exc_type = m.exc_info[0]
if type(exc_type) is ClassType and \
issubclass(exc_type, ConflictError):
delay_uid_list.append(uid)
elif priority > MAX_PRIORITY:
notify_user_list.append(m)
......
......@@ -198,8 +198,9 @@ class SQLQueue(RAMQueue, SQLBase):
if m.active_process:
message_with_active_process_list.append(m)
else:
if type(m.exc_type) is ClassType and \
issubclass(m.exc_type, ConflictError):
exc_type = m.exc_info[0]
if type(exc_type) is ClassType and \
issubclass(exc_type, ConflictError):
delay_uid_list.append(uid)
elif priority > MAX_PRIORITY:
notify_user_list.append(m)
......
......@@ -117,9 +117,7 @@ class Message:
self.args = args
self.kw = kw
self.is_executed = 0
self.exc_type = None
self.exc_value = None
self.traceback = None
self.exc_info = (None, None, None)
self.processing = None
self.user_name = str(_getAuthenticatedUser(self))
# Store REQUEST Info ?
......@@ -201,16 +199,13 @@ class Message:
self.is_executed = 1
except:
self.is_executed = 0
self.exc_type = sys.exc_info()[0]
self.exc_value = str(sys.exc_info()[1])
self.traceback = ''.join(ExceptionFormatter.format_exception(
*sys.exc_info()))
self.exc_info = sys.exc_info()
LOG('ActivityTool', WARNING,
'Could not call method %s on object %s' % (
self.method_id, self.object_path), error=sys.exc_info())
self.method_id, self.object_path), error=self.exc_info)
# push the error in ZODB error_log
if getattr(activity_tool, 'error_log', None) is not None:
activity_tool.error_log.raising(sys.exc_info())
activity_tool.error_log.raising(self.exc_info)
def validate(self, activity, activity_tool, check_order_validation=1):
return activity.validate(activity_tool, self,
......@@ -238,16 +233,17 @@ Subject: %s
Document: %s
Method: %s
Exception: %s %s
%s
""" % (activity_tool.email_from_address, user_email, message,
message, '/'.join(self.object_path), self.method_id,
self.exc_type, self.exc_value, self.traceback)
''.join(ExceptionFormatter.format_exception(*self.exc_info)))
try:
activity_tool.MailHost.send( mail_text )
except (socket.error, MailHostError), message:
LOG('ActivityTool.notifyUser', WARNING, 'Mail containing failure information failed to be sent: %s. Exception was: %s %s\n%s' % (message, self.exc_type, self.exc_value, self.traceback))
except (socket.error, MailHostError):
LOG('ActivityTool.notifyUser', WARNING, 'Mail containing failure information failed to be sent.', error=sys.exc_info())
if self.exc_info[0] is not None:
LOG('ActivityTool.notifyUser', WARNING, 'Original exception', error=self.exc_info)
def reactivate(self, activity_tool):
# Reactivate the original object.
......@@ -843,10 +839,10 @@ class ActivityTool (Folder, UniqueObject):
new_message_list.append(m)
except:
m.is_executed = 0
m.exc_type = sys.exc_info()[0]
m.exc_info = sys.exc_info()
LOG('WARNING ActivityTool', 0,
'Could not call method %s on object %s' %
(m.method_id, m.object_path), error=sys.exc_info())
(m.method_id, m.object_path), error=m.exc_info)
try:
if len(expanded_object_list) > 0:
......@@ -861,10 +857,10 @@ class ActivityTool (Folder, UniqueObject):
# In this case, the group method completely failed.
for m in new_message_list:
m.is_executed = 0
m.exc_type = sys.exc_info()[0]
m.exc_info = sys.exc_info()
LOG('WARNING ActivityTool', 0,
'Could not call method %s on objects %s' %
(method_id, expanded_object_list), error=sys.exc_info())
(method_id, expanded_object_list), error=m.exc_info)
else:
# Obtain all indices of failed messages. Note that this can be a partial failure.
failed_message_dict = {}
......@@ -888,10 +884,10 @@ class ActivityTool (Folder, UniqueObject):
m.is_executed = 1
except:
m.is_executed = 0
m.exc_type = sys.exc_info()[0]
m.exc_info = sys.exc_info()
LOG('ActivityTool', WARNING,
'Could not call method %s on object %s' % (
m.method_id, m.object_path), error=sys.exc_info())
m.method_id, m.object_path), error=m.exc_info)
def newMessage(self, activity, path, active_process,
activity_kw, method_id, *args, **kw):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment