Esempio n. 1
0
def abort(http_status_code, **kwargs):
    """Raise a HTTPException for the given http_status_code. Attach any keyword
    arguments to the exception for later processing.
    """
    #noinspection PyUnresolvedReferences
    try:
        original_flask_abort(http_status_code)
    except HTTPException as e:
        e.data = kwargs
        raise e
Esempio n. 2
0
def abort(http_status_code, **kwargs):
    """Raise a HTTPException for the given http_status_code. Attach any keyword
    arguments to the exception for later processing.
    """
    #noinspection PyUnresolvedReferences
    try:
        original_flask_abort(http_status_code)
    except HTTPException as e:
        if len(kwargs):
            e.data = kwargs
        raise
Esempio n. 3
0
def abort(http_status_code, *args, **kwargs):
    """
    Rest style flask abort wrapper
    """
    try:
        original_flask_abort(http_status_code)
    except HTTPException as e:
        e.data = kwargs
        if len(args):
            e.data['_errors'] = args
        raise
Esempio n. 4
0
 def abort(cls, http_status_code, **kwargs):
     """Raise a HTTPException for the given http_status_code. Attach any keyword
     arguments to the exception for later processing.
     用于覆盖原flask-restful中的abort,从而实现自定义参数验证错误信息。
     """
     try:
         original_flask_abort(http_status_code)
     except HTTPException as e:
         if len(kwargs):
             e.data = cls._make_parameter_error_response(
                 http_status_code=e.code, data=kwargs)
         raise
Esempio n. 5
0
def abort(http_status_code, **kwargs):
    """Raise a HTTPException for the given http_status_code. Attach any keyword
    arguments to the exception for later processing.
    """
    # noinspection PyUnresolvedReferences
    try:
        hint = kwargs.get('message')
        if isinstance(hint, dict):
            msg = ','.join(hint.values())
            original_flask_abort(send(http_status_code, data=hint, msg=msg))
        else:
            original_flask_abort(send(http_status_code, data=hint))
    except HTTPException as e:
        if len(kwargs):
            e.data = kwargs
        raise