txt = traceback.format_exc(None).decode('utf-8', 'ignore') pyas2init.logger.error( _(u'Unexpected error while processing message %(msg)s, ' u'error:\n%(txt)s'), { 'txt': txt, 'msg': message.message_id }) status = 'error' adv_status = 'unexpected-processing-error' status_message = _(u'An error occurred during the AS2' u' message processing: \n %s' % txt) finally: # Build the mdn for the message based on processing status mdn_body, mdn_message = as2lib.build_mdn( message, status, adv_status=adv_status, status_message=status_message) # Create the mdn response body and return the MDN to the http request if mdn_body: mdn_response = HttpResponse( mdn_body, content_type=mdn_message.get_content_type()) for key, value in mdn_message.items(): mdn_response[key] = value return mdn_response else: return HttpResponse( _(u'AS2 message has been received'))
except as2utils.As2InvalidSignature, e: status = 'error' adv_status = 'integrity-check-failed' status_message = _(u'An error occurred during the AS2 message processing: %s' % e) except Exception, e: txt = traceback.format_exc(None).decode('utf-8', 'ignore') pyas2init.logger.error(_(u'Unexpected error while processing message %(msg)s, ' u'error:\n%(txt)s'), {'txt': txt, 'msg': message.message_id}) status = 'error' adv_status = 'unexpected-processing-error' status_message = _(u'An error occurred during the AS2 message processing: %s' % e) finally: # Build the mdn for the message based on processing status mdn_body, mdn_message = as2lib.build_mdn(message, status, adv_status=adv_status, status_message=status_message) # Create the mdn response body and return the MDN to the http request if mdn_body: mdn_response = HttpResponse(mdn_body, content_type=mdn_message.get_content_type()) for key, value in mdn_message.items(): mdn_response[key] = value return mdn_response else: return HttpResponse(_(u'AS2 message has been received')) # Catch all exception in case of any kind of error in the system. except Exception: txt = traceback.format_exc(None).decode('utf-8', 'ignore') report_txt = _(u'Fatal error while processing message %(msg)s, '