Method for handling the actual exceptions

@param  \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event [description]
439714
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        $exception = $event->getException();

        if ($exception instanceof HttpException) {
            return;
        }

        $this->client->notifyOnException($exception);
        error_log($exception->getMessage().' in: '.$exception->getFile().':'.$exception->getLine());
    }
1182429
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->getException()) {
            $this->notifier->reportException($this->getException());
            $this->setException(null);
        }
    }
1092387
public function onBootException(GetResponseForExceptionEvent $event)
    {
        if ($this->isProfilerRequest($event->getRequest())) {
            return;
        }

        $exception = $event->getException();
        if ($exception instanceof BootException) {
            $event->setResponse($exception->getResponse());
        }
    }
997148
public function onKernelExceptionView(GetResponseForExceptionEvent $event)
    {
        if (!$event->getRequest()->attributes->get('is_rest_request')) {
            return;
        }

        $event->setResponse(
            $this->viewDispatcher->dispatch(
                $event->getRequest(),
                $event->getException()
            )
        );
        $event->stopPropagation();
    }
120816
protected function handleException($exception, MvcEvent $event, EventManagerInterface $events)
    {
        // Prepare error event
        $event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
        $event->setError(static::ERROR_EXCEPTION);
        $event->setParam('exception', $exception);

        // Trigger route event
        $result   = $events->triggerEvent($event);
        $response = $result->last();

        if ($response instanceof ResponseInterface) {
            return $this->completeResponse($events, $event, $response);
        }

        return $this->completeRequest($event);
    }
1122788
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if ($event->getException() instanceof NotFoundHttpException && $this->cmsManagerSelector->isEditor()) {
            $pathInfo = $event->getRequest()->getPathInfo();

            // can only create a CMS page, so the '_route' must be null
            $creatable = !$event->getRequest()->get('_route') && $this->decoratorStrategy->isRouteUriDecorable($pathInfo);

            if ($creatable) {
                $response = new Response($this->templating->render('@SonataPage/Page/create.html.twig', [
                    'pathInfo' => $pathInfo,
                    'site' => $this->siteSelector->retrieve(),
                    'creatable' => $creatable,
                ]), 404);

                $event->setResponse($response);
                $event->stopPropagation();

                return;
            }
        }

        if ($event->getException() instanceof InternalErrorException) {
            $this->handleInternalError($event);
        } else {
            $this->handleNativeError($event);
        }
    }
448094
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $requestToken = $this->getToken(
            $request->headers->get($this->options['header_name'], null)
        );

        if (!empty($requestToken)) {
            try {
                $decoded = $this->encode->decode($requestToken);
                $user = null;
                if (isset($decoded->{$this->options['username_claim']})) {
                    $user = $decoded->{$this->options['username_claim']};
                }

                $token = new JWTToken(
                    $user,
                    $requestToken,
                    $this->providerKey
                );

                $authToken = $this->authenticationManager->authenticate($token);
                $this->securityContext->setToken($authToken);

            } catch (HttpEncodingException $e) {
            } catch (\UnexpectedValueException $e) {
            }
        }
    }
963458
public function handle(GetResponseEvent $event)
    {
        if (!$this->registered && null !== $this->dispatcher && $event->isMasterRequest()) {
            $this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
            $this->registered = true;
        }

        $request = $event->getRequest();
        $session = $request->getSession();
        /*$sessionId = $session->getId();
        if(empty($sessionId))
        {
            $session = null;
        }*/

        if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) {
            $this->context->setToken(null);

            return;
        }

        $token = unserialize($token);

        if (null !== $this->logger) {
            $this->logger->debug('Read SecurityContext from the session');
        }

        if ($token instanceof TokenInterface) {
            $token = $this->refreshUser($token);
        } elseif (null !== $token) {
            if (null !== $this->logger) {
                $this->logger->warning(sprintf('Session includes a "%s" where a security token is expected', is_object($token) ? get_class($token) : gettype($token)));
            }

            $token = null;
        }

        $this->context->setToken($token);
    }
821030
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        $request = $event->getRequest();
        $exception = $event->getException();
        if (!$exception instanceof HttpExceptionInterface || Zone::isBackend($request)) {
            return;
        }
        if ($exception->getStatusCode() !== Response::HTTP_NOT_FOUND) {
            return;
        }
        // If no zone is set, assume front-end as SELECT queries can leak unpublished records
        if (Zone::get($request) === null) {
            Zone::set($request, Zone::FRONTEND);
        }

        foreach ($this->notFoundPage as $item) {
            try {
                $this->renderNotFound($event, $item);

                return;
            } catch (LoaderError $e) {
                // Template not found, fall though to see if we can render a
                // record, failing that let the exception handler take over
            }

            $content = $this->storage->getContent($item, ['returnsingle' => true]);
            if ($content instanceof Content && !empty($content->id)) {
                $template = $this->templateChooser->record($content);
                $this->renderNotFound($event, $template, $content->getTemplateContext());

                return;
            }
        }

        $msg = sprintf(
            'No page could be shown, because the "notfound" setting "%s" in config.yml or theme.yml is not valid.',
            implode(', ', $this->notFoundPage)
        );
        $event->setException(new NotFoundHttpException($msg, $e));
    }
243185
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $request = $event->getRequest();

        if ($this->kernelDebug && $this->debugParameter && $request->query->has($this->debugParameter)) {
            return;
        }

        $exception = $event->getException();
        $errorPresentation = $this->errorPresentationFactory->create($exception);

        if (!$errorPresentation) {
            return;
        }

        if (!$errorPresentation->getResource()) {
            // The presentation not have resource. Send response with only status code.
            $event->setResponse(new Response('', $errorPresentation->getStatusCode()));

            return;
        }

        $acceptMediaType = null;

        try {
            $serializer = $this->serializerResolver->resolveByMediaTypes(
                get_class($errorPresentation->getResource()),
                $request->getAcceptableContentTypes(),
                $acceptMediaType
            );
        } catch (ResourceSerializerNotFoundException $e) {
            // Cannot resolve the serializer for accept media types.

            return;
        }

        $context = $this->serializationContextCollector->collect();
        $serializedData = $serializer->serialize($errorPresentation->getResource(), $context);

        $response = new Response($serializedData, $errorPresentation->getStatusCode(), [
            'Content-Type' => $acceptMediaType,
        ]);

        $event->setResponse($response);
    }
337612
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        $exception = $event->getException();

        // Should return a error 400 bad request
        if ($exception instanceof ValidationException
         || $exception instanceof SyntaxErrorException) {
            return;
        }

        // Some Exceptions have status code and if 400 it should be handled by them
        if (method_exists($exception, 'getStatusCode')
            && (400 == (int)$exception->getStatusCode())) {
            return;
        }

        $data = $this->decorateKnownCases($exception);

        if (!is_array($data)) {
            $data = [
                'code' => $exception->getCode(),
                'exceptionClass' => get_class($exception),
                'message' => $exception->getMessage()
            ];

            if ($exception->getPrevious() instanceof \Exception) {
                $data['innerMessage'] = $exception->getPrevious()->getMessage();
            }
        }

        if ($this->logger instanceof Logger) {
            $this->logger->critical($exception);
        }

        $response = new JsonResponse($data);
        $event->setResponse($response);
    }
850370
public function onClientRequest(RequestEvent $event)
    {
        $errors = $this->validator->validate($event->getRequest());

        if (count($errors)) {
            throw new RequestException((string) $errors);
        }
    }
983732
public function handleHandleHttpRequestEvent(HandleHttpRequestEvent $event) {
        $event->setResponse(
            $this->requestHandler->handle($event->getRequest())
        );
    }
497201
public function onError(ErrorEvent $event)
    {
        $request = $event->getRequest();

        if (!call_user_func($this->canCache, $request)) {
            return;
        }

        $response = $this->storage->fetch($request);

        // Intercept the failed response if possible
        if ($response && $this->validateFailed($request, $response)) {
            $request->getConfig()->set('cache_hit', 'error');
            $response->setHeader('Age', Utils::getResponseAge($response));
            $event->intercept($response);
        }
    }
764345
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if (($exception = $event->getException()) instanceof SerializationException) {
            $response = $exception->getResponse()
                ->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);

            $event->setResponse($response);
        }
    }
186418
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $this->originListener->onKernelException($event);

        if (!$event->hasResponse()) {
            // The origin listener not processed.
            return;
        }

        $this->logException($event->getException());
    }
40691
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { // don't do anything if it's not the master request

            return;
        }

        // We get the exception object from the received event
        $exception = FlattenException::create($event->getException());

        // We get the request
        $request = $event->getRequest();

        // Process the exception
        return $this->logException($exception, $request);
    }