Handle the exception and log message.

@param GetResponseForExceptionEvent $event
186418
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $this->originListener->onKernelException($event);

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

        $this->logException($event->getException());
    }
316449
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        $exception = $event->getException();
        if ($exception instanceof HttpException) {
            return;
        }
        $culprit = null;
        if ($event->getRequest()->attributes->has("_controller")) {
            $culprit = $event->getRequest()->attributes->get("_controller");
        }
        $event_id = $this->client->getIdent($this->client->captureException($exception, $culprit, $this->client->getEnvironment()));

        return error_log("[$event_id] " . $exception->getMessage() . ' in: ' . $exception->getFile() . ':' . $exception->getLine());
    }
1077651
public function onException(GetResponseForExceptionEvent $event)
    {
        if ($event->isMasterRequest()) {
            return;
        }

        $exception = $event->getException();

        $level = LogLevel::CRITICAL;
        if ($exception instanceof HttpExceptionInterface && $exception->getStatusCode() < 500) {
            $level = LogLevel::WARNING;
        }

        $this->logger->log($level, $exception->getMessage(), ['event' => 'exception', 'exception' => $exception]);
    }
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);
    }
513672
private function isAdminException(GetResponseForExceptionEvent $event): bool
    {
        $request = $event->getRequest();

        /** @var SiteAccess $siteAccess */
        $siteAccess = $request->get('siteaccess', new SiteAccess());

        return in_array($siteAccess->name, $this->siteAccessGroups[EzPlatformAdminUiBundle::ADMIN_GROUP_NAME]);
    }
1225433
public function onException(GetResponseForExceptionEvent $event): void
    {
        $attributes = $event->getRequest()->attributes;
        if ($attributes->get(SetIsAdminRequestListener::ADMIN_FLAG_NAME) !== true) {
            return;
        }

        if (!$event->getRequest()->isXmlHttpRequest()) {
            return;
        }

        $exception = $event->getException();
        if (!$exception instanceof AuthenticationException && !$exception instanceof AccessDeniedException) {
            return;
        }

        $event->setException(new AccessDeniedHttpException());

        $event->stopPropagation();
    }
146960
protected function handleEvent($event)
    {
        if (!is_null($response = $this->call('event.*', array($event)))) {
            return $response;
        }

        $event['Event'] = strtolower($event['Event']);

        return $this->call("event.{$event['Event']}", array($event));
    }
1184894
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if (($exception = $event->getException()) instanceof RecordOriginModifiedException) {
            $content = array(
                "propertyPath" => "recordOrigin",
                "message"      => $exception->getMessage(),
            );

            // Set status code and content
            $response = new Response();
            $response
                ->setStatusCode($exception->getStatusCode())
                ->setContent(
                    $this->getSerializedContent($content)
                );

            $event->setResponse($response);
        }
    }
150743
private function handleInternalError(GetResponseForExceptionEvent $event)
    {
        if (false === $this->debug) {
            $this->logger->error($event->getException()->getMessage(), [
                'exception' => $event->getException(),
            ]);

            return;
        }

        $content = $this->templating->render('@SonataPage/internal_error.html.twig', [
            'exception' => $event->getException(),
        ]);

        $event->setResponse(new Response($content, 500));
    }
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);
    }
441149
public function onCoreException(GetResponseForExceptionEvent $event)
    {
        $exception = $event->getException();
        $request = $event->getRequest();

        if ($request->isXmlHttpRequest()
            && get_class($exception) == 'Symfony\Component\Security\Core\Exception\AccessDeniedException') {
            $form = $this->templating->render(
                'ClarolineCoreBundle:Authentication:loginAjaxForm.html.twig'
            );

            //@see https://github.com/gillest/HackSessionBundle
            if (!$request->hasPreviousSession()) {
                $request->cookies->set(session_name(), 'tmp');
                $request->setSession($this->session);
            }

            $event->setResponse(new Response($form, 403));
        }
    }
132099
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        $exception = $event->getException();
        if (! $exception instanceof RedKiteCmsExceptionInterface) {
            return;
        }

        $message = $exception->getMessage();
        $jsonMessage = json_decode($message, true);
        if ( ! is_array($jsonMessage)) {
            $jsonMessage = array(
                'message' => $message,
            );
        }

        $parameters = array(
            'message' => '',
            'parameters' => array(),
            'domain' => 'RedKiteCmsBundle',
            'locale' => null,
        );
        $cleanedParameters = array_intersect_key($jsonMessage, $parameters);
        $parameters = array_merge($parameters, $cleanedParameters);

        $message = $this->translator->translate(
            $parameters["message"],
            $parameters["parameters"],
            $parameters["domain"],
            $parameters["locale"]
        );

        $response = $this->templating->renderResponse(
            'RedKiteCmsBundle:Dialog:dialog.html.twig',
            array(
                'message' => $message,
            )
        );
        $response->setStatusCode(404);
        $event->setResponse($response);
    }
324550
protected function _exceptionResponse(Event $Event, $exceptionConfig)
    {
        $exceptionConfig = array_merge($this->getConfig('exception'), $exceptionConfig);

        $class = $exceptionConfig['class'];

        if ($exceptionConfig['type'] === 'validate') {
            $exception = new $class($Event->getSubject()->entity);
            throw $exception;
        }

        $exception = new $class($exceptionConfig['message'], $exceptionConfig['code']);
        throw $exception;
    }
314793
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $exception = $event->getException();

        if (!$exception instanceof AccessDeniedException) {
            return;
        }

        $event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
    }
1238833
public function onConsoleException(ConsoleExceptionEvent $event)
    {
        $call = $this->callRepository->find($_REQUEST['call_id']);

        $call->setStatus(Call::STATUS_FAILED)
            ->setOutput($event->getException());

        $this->callRepository->update($call);

        $this->registerError($call);
    }
1297065
protected function handleBadUserRoleException(GetResponseForExceptionEvent $event, BadUserRoleException $ex) {
        if (null !== $ex->getRedirectUrl()) {
            $event->setResponse(new RedirectResponse($ex->getRedirectUrl()));
        }
        return $event;
    }
810688
public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $application = $event->getKernel()->getApplication();

        if (null !== $application && false === $request->hasSession()) {
            $container = $application->getContainer();
            $event->getRequest()->setSession($container->get('bb_session'));
        }

        parent::handle($event);
    }