public function ExceptionLoggingSubscriber::onException

public ExceptionLoggingSubscriber::onException(GetResponseForExceptionEvent $event)

Log all exceptions.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event: The event to process.

File

core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php, line 79

Class

ExceptionLoggingSubscriber
Log exceptions without further handling.

Namespace

Drupal\Core\EventSubscriber

Code

public function onException(GetResponseForExceptionEvent $event) {
  $exception = $event->getException();

  $method = 'onError';

  // Treat any non-HTTP exception as if it were one, so we log it the same.
  if ($exception instanceof HttpExceptionInterface) {
    $possible_method = 'on' . $exception->getStatusCode();
    if (method_exists($this, $possible_method)) {
      $method = $possible_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!ExceptionLoggingSubscriber.php/function/ExceptionLoggingSubscriber::onException/8.1.x