本文整理匯總了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