$redirect = $this->redirecter->lookupRedirect($requestUri);
if ($redirect) {
$response = new RedirectResponse($redirect);
$event->setResponse($response);
} else {
throw new NotFoundHttpException(
'Sorry, the book you requested does not exist. Please check the URL and try again!'
);
}
}
}
$this->called = true;
$this->priority = $dispatcher->getListenerPriority($eventName, $this->listener);
$e = $this->stopwatch->start($this->name, 'event_listener');
($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
if ($e->isStarted()) {
$e->stop();
}
foreach ($listeners as $listener) {
if ($stoppable && $event->isPropagationStopped()) {
break;
}
$listener($event, $eventName, $this);
}
}
/**
* Sorts the internal list of listeners for the given event by priority.
} else {
$listeners = $this->getListeners($eventName);
}
if ($listeners) {
$this->callListeners($listeners, $eventName, $event);
}
return $event;
}
try {
$this->beforeDispatch($eventName, $event);
try {
$e = $this->stopwatch->start($eventName, 'section');
try {
$this->dispatcher->dispatch($event, $eventName);
} finally {
if ($e->isStarted()) {
$e->stop();
}
}
* @throws \Exception
*/
private function handleThrowable(\Throwable $e, Request $request, int $type): Response
{
$event = new ExceptionEvent($this, $request, $type, $e);
$this->dispatcher->dispatch($event, KernelEvents::EXCEPTION);
// a listener might have replaced the exception
$e = $event->getThrowable();
if (!$event->hasResponse()) {
{
if (!$request = $request ?: $this->requestStack->getMainRequest()) {
throw $exception;
}
$response = $this->handleThrowable($exception, $request, self::MAIN_REQUEST);
$response->sendHeaders();
$response->sendContent();
$this->terminate($request, $response);
if ($hasRun) {
throw $e;
}
$hasRun = true;
$kernel->terminateWithException($e, $request);
};
}
} elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) {
$output = $event->getOutput();
if ($output instanceof ConsoleOutputInterface) {
$this->exceptionHandler = null;
}
try {
if (null !== $exceptionHandler) {
return $exceptionHandler($exception);
}
$handlerException = $handlerException ?: $exception;
} catch (\Throwable $handlerException) {
}
if ($exception === $handlerException && null === $this->exceptionHandler) {
NotFoundHttpException
|
---|
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: Sorry, the book you requested does not exist. Please check the URL and try again! at /var/www/civicrm-docs/src/EventSubscriber/ExceptionSubscriber.php:31 at App\EventSubscriber\ExceptionSubscriber->onExceptionEvent() (/var/www/civicrm-docs/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:111) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke() (/var/www/civicrm-docs/vendor/symfony/event-dispatcher/EventDispatcher.php:230) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (/var/www/civicrm-docs/vendor/symfony/event-dispatcher/EventDispatcher.php:59) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (/var/www/civicrm-docs/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:152) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() (/var/www/civicrm-docs/vendor/symfony/http-kernel/HttpKernel.php:213) at Symfony\Component\HttpKernel\HttpKernel->handleThrowable() (/var/www/civicrm-docs/vendor/symfony/http-kernel/HttpKernel.php:106) at Symfony\Component\HttpKernel\HttpKernel->terminateWithException() (/var/www/civicrm-docs/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:125) at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::Symfony\Component\HttpKernel\EventListener\{closure}() (/var/www/civicrm-docs/vendor/symfony/error-handler/ErrorHandler.php:541) at Symfony\Component\ErrorHandler\ErrorHandler->handleException() |