You are here

public function ExceptionLoggingSubscriber::onException in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber::onException()

Log all exceptions.

Parameters

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

File

core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php, line 84
Contains \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber.

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);
}