public HttpExceptionSubscriberBase::onException(GetResponseForExceptionEvent $event)
Handles errors for this subscriber.
\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event: The event to process.
public function onException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); // Make the exception available for example when rendering a block. $request = $event->getRequest(); $request->attributes->set('exception', $exception); $handled_formats = $this->getHandledFormats(); $format = $request->query->get(MainContentViewSubscriber::WRAPPER_FORMAT, $request->getRequestFormat()); if ($exception instanceof HttpExceptionInterface && (empty($handled_formats) || in_array($format, $handled_formats))) { $method = 'on' . $exception->getStatusCode(); // We want to allow the method to be called and still not set a response // if it has additional filtering logic to determine when it will apply. // It is therefore the method's responsibility to set the response on the // event if appropriate. if (method_exists($this, $method)) { $this->$method($event); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!EventSubscriber!HttpExceptionSubscriberBase.php/function/HttpExceptionSubscriberBase::onException/8.1.x