public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if ($this->isProfilerRequest($event->getRequest())) {
            return;
        }

        $exception = $event->getException();

        if ($exception instanceof DatabaseExceptionInterface) {
            $html = $this->renderDatabaseException($exception);
        } elseif ($exception instanceof AbstractSystemValidationException) {
            $html = $this->renderSystemValidationException($exception);
        } else {
            $html = $this->renderException($exception);
        }

        $statusCode = $exception instanceof HttpExceptionInterface ?
            $exception->getStatusCode() :
            Response::HTTP_INTERNAL_SERVER_ERROR;
        $response = new Response($html, $statusCode, ['X-Debug-Exception-Handled' => time()]);

        $event->setResponse($response);
    }
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if ($this->isProfilerRequest($event->getRequest())) {
            return;
        }

        $exception = $event->getException();

        if ($exception instanceof DatabaseExceptionInterface) {
            $html = $this->renderDatabaseException($exception);
        } elseif ($exception instanceof AbstractSystemValidationException) {
            $html = $this->renderSystemValidationException($exception);
        } else {
            $html = $this->renderException($exception);
        }

        $statusCode = $exception instanceof HttpExceptionInterface ?
            $exception->getStatusCode() :
            Response::HTTP_INTERNAL_SERVER_ERROR;
        $response = new Response($html, $statusCode, ['X-Debug-Exception-Handled' => time()]);

        $event->setResponse($response);
    }
public function onKernelException ( GetResponseForExceptionEvent $ event ) { if ( $ this -> isProfilerRequest ( $ event -> getRequest ( ) ) ) { return ; } $ exception = $ event -> getException ( ) ; if ( $ exception instanceof DatabaseExceptionInterface ) { $ html = $ this -> renderDatabaseException ( $ exception ) ; } elseif ( $ exception instanceof AbstractSystemValidationException ) { $ html = $ this -> renderSystemValidationException ( $ exception ) ; } else { $ html = $ this -> renderException ( $ exception ) ; } $ statusCode = $ exception instanceof HttpExceptionInterface ? $ exception -> getStatusCode ( ) : Response :: HTTP_INTERNAL_SERVER_ERROR ; $ response = new Response ( $ html , $ statusCode , [ 'X-Debug-Exception-Handled' => time ( ) ] ) ; $ event -> setResponse ( $ response ) ; }
Handle errors thrown in the application.

@param GetResponseForExceptionEvent $event
Handle errors thrown in the application .