exception.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:ws-backend-community 作者: lavalamp- 项目源码 文件源码
def web_sight_exception_handler(exc, context):
    """
    This is a custom Django exception handler that handles all exceptions thrown by the Web Sight REST
    API.
    :param exc: The exception that was thrown.
    :param context: The context in which the exception was thrown.
    :return: A response to return to the requesting user.
    """
    if isinstance(exc, IntegrityError):
        return handle_integrity_error(exc, context)
    elif isinstance(exc, ValidationError):
        return handle_validation_error(exc, context)
    elif isinstance(exc, WsRestNonFieldException):
        return handle_non_field_error(exc, context)
    elif isinstance(exc, APIException):
        return handle_api_exception(exc, context)
    else:
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号