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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.