本文整理汇总了Python中aiohttp.web_exceptions.HTTPException方法的典型用法代码示例。如果您正苦于以下问题:Python web_exceptions.HTTPException方法的具体用法?Python web_exceptions.HTTPException怎么用?Python web_exceptions.HTTPException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiohttp.web_exceptions
的用法示例。
在下文中一共展示了web_exceptions.HTTPException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_middleware_with_handler_404
# 需要导入模块: from aiohttp import web_exceptions [as 别名]
# 或者: from aiohttp.web_exceptions import HTTPException [as 别名]
def test_middleware_with_handler_404(tracer):
app = web.Application()
az.setup(app, tracer)
async def handler(request):
raise HTTPNotFound
req = make_mocked_request('GET', '/', headers={'token': 'x'}, app=app)
middleware = middleware_maker()
with pytest.raises(HTTPException):
await middleware(req, handler)
示例2: debug_factory
# 需要导入模块: from aiohttp import web_exceptions [as 别名]
# 或者: from aiohttp.web_exceptions import HTTPException [as 别名]
def debug_factory(app, handler):
async def debug_middleware(request):
try:
response = await handler(request)
except HTTPException:
raise
except:
logger.exception('ERROR')
raise
return response
return debug_middleware