0001-can-notify-exceptions-on-formdata-only-in-UI-24327.patch
tests/test_hobo_notify.py | ||
---|---|---|
587 | 587 |
else: # empty value : empty field |
588 | 588 |
assert User.select()[0].form_data['_birthdate'] is None |
589 | 589 | |
590 |
def notify_of_exception(exc_info, context): |
|
590 |
def notify_of_exception(exc_info, context=None, formdata=None):
|
|
591 | 591 |
raise Exception(exc_info) |
592 | 592 | |
593 | 593 |
def test_process_notification_user_with_errors(pub): |
wcs/logged_errors.py | ||
---|---|---|
47 | 47 |
('acked', 'bool')] |
48 | 48 | |
49 | 49 |
@classmethod |
50 |
def record(cls, error_summary, plain_error_msg, publisher): |
|
50 |
def record(cls, error_summary, plain_error_msg, publisher=None, formdata=None):
|
|
51 | 51 |
error = cls() |
52 | 52 |
error.summary = error_summary |
53 | 53 |
error.traceback = plain_error_msg |
54 |
try: |
|
55 |
context = publisher.substitutions.get_context_variables() |
|
56 |
except: |
|
57 |
return |
|
58 | 54 | |
59 |
formdef_urlname = context.get('form_slug') |
|
60 |
if not formdef_urlname: |
|
55 |
if formdata: |
|
56 |
error.formdata_id = str(formdata.id) |
|
57 |
error.formdef_id = formdata.formdef.id |
|
58 |
error.workflow_id = formdata.formdef.workflow_id |
|
59 | ||
60 |
elif publisher: |
|
61 |
try: |
|
62 |
context = publisher.substitutions.get_context_variables() |
|
63 |
except Exception as e: |
|
64 |
return |
|
65 |
error.formdata_id = context.get('form_number_raw') |
|
66 |
formdef_urlname = context.get('form_slug') |
|
67 |
if formdef_urlname: |
|
68 |
formdef = FormDef.get_by_urlname(formdef_urlname) |
|
69 |
error.formdef_id = formdef.id |
|
70 |
error.workflow_id = formdef.workflow_id |
|
71 | ||
72 |
if not error.formdef_id: |
|
61 | 73 |
# cannot attach error to formdef, don't record in journal, it will |
62 | 74 |
# still be sent by email to administrators. |
63 | 75 |
return |
64 | 76 | |
65 |
error.formdata_id = context.get('form_number_raw') |
|
66 |
if formdef_urlname: |
|
67 |
formdef = FormDef.get_by_urlname(formdef_urlname) |
|
68 |
error.formdef_id = formdef.id |
|
69 |
error.workflow_id = formdef.workflow_id |
|
70 | ||
71 | 77 |
error.first_occurence_timestamp = datetime.datetime.now() |
72 | 78 |
error.id = '%s-%s' % ( |
73 | 79 |
error.first_occurence_timestamp.strftime('%Y%m%d-%H%M%S'), |
wcs/publisher.py | ||
---|---|---|
283 | 283 |
conn.commit() |
284 | 284 |
cur.close() |
285 | 285 | |
286 |
def log_internal_error(self, error_summary, plain_error_msg, record=False): |
|
287 |
super(WcsPublisher, self).log_internal_error(error_summary, |
|
288 |
plain_error_msg, record=record) |
|
286 |
def log_internal_error(self, error_summary, plain_error_msg, record=False, formdata=None): |
|
287 |
if not formdata: |
|
288 |
super(WcsPublisher, self).log_internal_error(error_summary, |
|
289 |
plain_error_msg, record=record) |
|
289 | 290 |
if record: |
290 |
LoggedError.record(error_summary, plain_error_msg, publisher=self) |
|
291 |
LoggedError.record(error_summary, plain_error_msg, publisher=self, formdata=formdata)
|
|
291 | 292 | |
292 | 293 |
def apply_global_action_timeouts(self): |
293 | 294 |
from wcs.workflows import Workflow, WorkflowGlobalActionTimeoutTrigger |
wcs/qommon/publisher.py | ||
---|---|---|
238 | 238 | |
239 | 239 |
return error_file.getvalue() |
240 | 240 | |
241 |
def notify_of_exception(self, exc_tuple, context=None): |
|
241 |
def notify_of_exception(self, exc_tuple, context=None, formdata=None):
|
|
242 | 242 |
exc_type, exc_value, tb = exc_tuple |
243 | 243 |
error_summary = traceback.format_exception_only(exc_type, exc_value) |
244 | 244 |
error_summary = error_summary[0][0:-1] # de-listify and strip newline |
... | ... | |
254 | 254 |
self.notify_sentry(exc_tuple, request=self.get_request(), |
255 | 255 |
context=context) |
256 | 256 | |
257 |
self.log_internal_error(error_summary, plain_error_msg, record=True) |
|
257 |
self.log_internal_error(error_summary, plain_error_msg, record=True, formdata=formdata)
|
|
258 | 258 | |
259 |
def log_internal_error(self, error_summary, plain_error_msg, record=False): |
|
259 |
def log_internal_error(self, error_summary, plain_error_msg, record=False, formdata=None):
|
|
260 | 260 |
try: |
261 | 261 |
self.logger.log_internal_error(error_summary, plain_error_msg) |
262 | 262 |
except socket.error: |
wcs/workflows.py | ||
---|---|---|
1725 | 1725 |
return [] |
1726 | 1726 | |
1727 | 1727 |
targets = [x for x in self.parent.parent.possible_status if x.id == self.status] |
1728 |
if not targets: |
|
1729 |
get_publisher().get_app_logger().error( |
|
1730 |
'reference to invalid status in workflow %r, status %r, item %r' % ( |
|
1731 |
self.parent.parent.name, |
|
1732 |
self.parent.name, |
|
1733 |
self.description)) |
|
1728 |
if not targets and formdata: # do not log in presentation context, formdata is needed |
|
1729 |
try: |
|
1730 |
raise IndexError('reference to invalid status in workflow %r, status %r, item %r' % |
|
1731 |
(self.parent.parent.name, self.parent.name, self.description)) |
|
1732 |
except IndexError as e: |
|
1733 |
get_publisher().notify_of_exception(sys.exc_info(), formdata=formdata) |
|
1734 | ||
1734 | 1735 |
return targets |
1735 | 1736 | |
1736 | 1737 |
def get_jump_label(self): |
1737 |
- |