def doFilter(self, request: Request, response: Response, chain: FilterChain): try: chain.doFilter(request, response) except Exception as e: exception_mapper = Stream(self.exception_mappers).firstMatch( lambda mapper: mapper.handles(e)) if exception_mapper.isPresent(): response.copy(exception_mapper.get().create_response(e)) else: raise e
def doFilter(self, request: Request, response: Response): if len(self.filters) == 0: gotten_response = None for invoker in self.route_handler_factory.create_route_handlers( request): try: gotten_response = invoker.invoke(request) except IncorrectResourceParametersException: continue if gotten_response is None: raise IncorrectResourceParametersException() response.copy(gotten_response) else: self.filters[0].doFilter(request, response, self.getNextChain())