public function handleException(\Exception $e): Response
    {
        if ($e instanceof NotFoundException) {
            $this->logger->info('404 Not Found: ' . $this->request->getRequestUri());
            $response = $this->provideNotFoundResponse();
        } elseif ($e instanceof MethodNotAllowedException) {
            $this->logger->notice('Method not allowed.', [
                'request_uri' => $this->request->getRequestUri(),
                'request_method' => $this->request->getRequestMethod(),
            ]);
            $response = $this->provideMethodNotAllowedResponse();
        } elseif ($e instanceof BadRequestException) {
            $this->logger->notice('Bad request.', [
                'request_uri' => $this->request->getRequestUri(),
                'request_method' => $this->request->getRequestMethod(),
            ]);
            $response = $this->provideBadRequestResponse();
        } else {
            $this->logger->error(sprintf('%s in %s:%d', $e->getMessage(), $e->getFile(), $e->getLine()));
            $response = $this->provideGeneralErrorResponse($e);
        }

        return $response;
    }
public function handleException(\Exception $e): Response
    {
        if ($e instanceof NotFoundException) {
            $this->logger->info('404 Not Found: ' . $this->request->getRequestUri());
            $response = $this->provideNotFoundResponse();
        } elseif ($e instanceof MethodNotAllowedException) {
            $this->logger->notice('Method not allowed.', [
                'request_uri' => $this->request->getRequestUri(),
                'request_method' => $this->request->getRequestMethod(),
            ]);
            $response = $this->provideMethodNotAllowedResponse();
        } elseif ($e instanceof BadRequestException) {
            $this->logger->notice('Bad request.', [
                'request_uri' => $this->request->getRequestUri(),
                'request_method' => $this->request->getRequestMethod(),
            ]);
            $response = $this->provideBadRequestResponse();
        } else {
            $this->logger->error(sprintf('%s in %s:%d', $e->getMessage(), $e->getFile(), $e->getLine()));
            $response = $this->provideGeneralErrorResponse($e);
        }

        return $response;
    }
public function handleException ( \ Exception $ e ) : Response { if ( $ e instanceof NotFoundException ) { $ this -> logger -> info ( '404 Not Found: ' . $ this -> request -> getRequestUri ( ) ) ; $ response = $ this -> provideNotFoundResponse ( ) ; } elseif ( $ e instanceof MethodNotAllowedException ) { $ this -> logger -> notice ( 'Method not allowed.' , [ 'request_uri' => $ this -> request -> getRequestUri ( ) , 'request_method' => $ this -> request -> getRequestMethod ( ) , ] ) ; $ response = $ this -> provideMethodNotAllowedResponse ( ) ; } elseif ( $ e instanceof BadRequestException ) { $ this -> logger -> notice ( 'Bad request.' , [ 'request_uri' => $ this -> request -> getRequestUri ( ) , 'request_method' => $ this -> request -> getRequestMethod ( ) , ] ) ; $ response = $ this -> provideBadRequestResponse ( ) ; } else { $ this -> logger -> error ( sprintf ( '%s in %s:%d' , $ e -> getMessage ( ) , $ e -> getFile ( ) , $ e -> getLine ( ) ) ) ; $ response = $ this -> provideGeneralErrorResponse ( $ e ) ; } return $ response ; }
Handles exceptions thrown by application.

@param \Exception $e
@return Response
Handles exceptions thrown by application .