utils.py 文件源码

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

项目:issue-reporting 作者: 6aika 项目源码 文件源码
def api_exception_handler(exc, context):
    # Call REST framework's default exception handler first,
    # to get the standard error response.
    from rest_framework.views import exception_handler
    response = exception_handler(exc, context)

    # Now add the HTTP status code to the response.
    if response is not None:
        response.data = {
            'code': response.status_code,
            'detail': response.reason_phrase
        }
        if hasattr(exc, 'detail'):
            response.data['detail'] = exc.detail

    return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号