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)
api_v1.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录