def start_session_with_error_handling(domain, contact, app, module, form,
        case_id, keyword, logged_subevent=None):
    try:
        session, responses = start_session(domain, contact, app, module,
            form, case_id=case_id, yield_responses=True)
        if logged_subevent:
            logged_subevent.xforms_session_id = session.pk
            logged_subevent.save()
        return (session, responses, False, None)
    except TouchformsError as e:
        human_readable_message = e.response_data.get('human_readable_message', None)
        logged_subevent.error(MessagingEvent.ERROR_TOUCHFORMS_ERROR,
            additional_error_text=human_readable_message)

        if touchforms_error_is_config_error(e):
            error_code = MSG_FORM_ERROR
        else:
            notify_exception(None, message=('Could not process structured sms for'
                'contact %s, domain %s, keyword %s' % (contact._id, domain, keyword)))
            error_code = MSG_TOUCHFORMS_ERROR

        return (None, None, True, error_code)
Returns (session, responses, error, error_code)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/handlers/keyword.py/start_session_with_error_handling