DefaultExceptionSubscriber::onException

public DefaultExceptionSubscriber::onException(GetResponseForExceptionEvent $event)

Handles errors for this subscriber.

Parameters

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

File

core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php, line 183

Class

DefaultExceptionSubscriber
Last-chance handler for exceptions.

Namespace

Drupal\Core\EventSubscriber

Code

public function onException(GetResponseForExceptionEvent $event) {
  $format = $this->getFormat($event->getRequest());
  $exception = $event->getException();

  $method = 'on' . $format;
  if (!method_exists($this, $method)) {
    if ($exception instanceof HttpExceptionInterface) {
      $this->onFormatUnknown($event);
      $response = $event->getResponse();
      $response->headers->set('Content-Type', 'text/plain');
    }
    else {
      $this->onHtml($event);
    }
  }
  else {
    $this->$method($event);
  }
}
doc_Drupal
2016-10-29 09:01:40
Comments
Leave a Comment

Please login to continue.