コード例 #1
0
ファイル: __init__.py プロジェクト: JosefJezek/flask-restful
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
コード例 #2
0
ファイル: __init__.py プロジェクト: zlaiyyf/dargonplus1.0.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
コード例 #3
0
ファイル: tools.py プロジェクト: Scille/kalon
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
コード例 #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
コード例 #5
0
ファイル: abort.py プロジェクト: mrvegazhou/stock_analysis
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