api_v1.py 文件源码

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

项目:fabric8-analytics-server 作者: fabric8-analytics 项目源码 文件源码
def error():
    """This endpoint is used by httpd, which redirects its errors to it."""
    try:
        status = int(request.environ['REDIRECT_STATUS'])
    except Exception:
        # if there's an exception, it means that a client accessed this directly;
        #  in this case, we want to make it look like the endpoint is not here
        return api_404_handler()
    msg = 'Unknown error'
    # for now, we just provide specific error for stuff that already happened;
    #  before adding more, I'd like to see them actually happening with reproducers
    if status == 401:
        msg = 'Authentication failed'
    elif status == 405:
        msg = 'Method not allowed for this endpoint'
    raise HTTPError(status, msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号