Ejemplo n.º 1
0
def _notify_submission_error(interface, instance, exception, message=None):
    from corehq.util.global_request.api import get_request
    request = get_request()
    error_message = u'{}: {}'.format(type(exception).__name__, unicode(exception))
    instance = interface.xformerror_from_xform_instance(instance, error_message, with_new_id=True)
    domain = getattr(instance, 'domain', '---')
    message = message or u"Error in case or stock processing"
    details = {
        'domain': domain,
        'original form ID': instance.orig_id,
        'error form ID': instance.form_id,
    }
    should_email = not isinstance(exception, CouchSaveAborted)  # intentionally don't double-email these
    if should_email:
        notify_exception(request, message, details=details)
    else:
        logging.error(message, exc_info=sys.exc_info(), extra={'details': details})
Ejemplo n.º 2
0
def _notify_submission_error(interface, instance, e):
    from corehq.util.global_request.api import get_request
    request = get_request()
    error_message = u'{}: {}'.format(type(e).__name__, unicode(e))
    instance = interface.xformerror_from_xform_instance(instance, error_message, with_new_id=True)
    domain = getattr(instance, 'domain', '---')
    message = u"Error in case or stock processing for domain: {}".format(domain)
    details = {
        'original form ID': instance.orig_id,
        'error form ID': instance.form_id,
        'error message': error_message
    }
    should_email = not isinstance(e, CouchSaveAborted)  # intentionally don't double-email these
    if should_email:
        notify_exception(request, message, details=details)
    else:
        logging.error(message, exc_info=sys.exc_info(), extra={'details': details})
Ejemplo n.º 3
0
 def test_get_and_set(self):
     obj = object()
     set_request(obj)
     self.assertEqual(obj, get_request())
Ejemplo n.º 4
0
 def test_get_and_set(self):
     obj = object()
     set_request(obj)
     self.assertEqual(obj, get_request())