def _get_submission_error(domain, instance, error):
    """
    Handle's a hard failure from posting a form to couch.
    :returns: xform error instance with raw xml as attachment
    """
    try:
        message = unicode(error)
    except __HOLE__:
        message = unicode(str(error), encoding='utf-8')

    xform = FormProcessorInterface(domain).submission_error_form_instance(instance, message)
    return FormProcessingResult(xform)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/form_processor/parsers/form.py/_get_submission_error