Exemplo n.º 1
0
    async def resolve(self,
                      request: IRequest) -> BaseMatchInfo:  # type: ignore
        """
        Resolve a request
        """
        request.record("start")
        result = None
        try:
            result = await self.real_resolve(request)
        except response.Response as exc:
            await abort()
            return BasicMatchInfo(request, exc)
        except asyncio.CancelledError:
            logger.info("Request cancelled", request=request)
            await abort()
            return BasicMatchInfo(request, response.HTTPClientClosedRequest())
        except Exception:
            logger.error("Exception on resolve execution",
                         exc_info=True,
                         request=request)
            await abort()
            return BasicMatchInfo(request, response.HTTPInternalServerError())

        if result is not None:
            return result
        else:
            await abort()
            return BasicMatchInfo(request, response.HTTPNotFound())
Exemplo n.º 2
0
    async def resolve(self,
                      request: IRequest) -> BaseMatchInfo:  # type: ignore
        '''
        Resolve a request
        '''
        # prevent: https://github.com/aio-libs/aiohttp/issues/3335
        request.url

        request.record('start')
        result = None
        try:
            result = await self.real_resolve(request)
        except (response.Response,
                aiohttp.web_exceptions.HTTPException) as exc:
            await abort()
            return BasicMatchInfo(request, exc)
        except Exception:
            logger.error("Exception on resolve execution",
                         exc_info=True,
                         request=request)
            await abort()
            return BasicMatchInfo(request, response.HTTPInternalServerError())

        if result is not None:
            return result
        else:
            await abort()
            return BasicMatchInfo(request, response.HTTPNotFound())
Exemplo n.º 3
0
    async def resolve(self, request: IRequest) -> MatchInfo:
        '''
        Resolve a request
        '''
        request.record('start')
        result = None
        try:
            result = await self.real_resolve(request)
        except (response.Response, aiohttp.web_exceptions.HTTPException) as exc:
            await abort(request)
            return BasicMatchInfo(request, exc)
        except Exception:
            logger.error("Exception on resolve execution",
                         exc_info=True, request=request)
            await abort(request)
            return BasicMatchInfo(
                request, response.HTTPInternalServerError())

        if result is not None:
            return result
        else:
            await abort(request)
            return BasicMatchInfo(request, response.HTTPNotFound())