function ExceptionLoggingSubscriber::onException
Same name in other branches
- 9 core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber::onException()
- 8.9.x core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber::onException()
- 11.x core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php \Drupal\Core\EventSubscriber\ExceptionLoggingSubscriber::onException()
Log all exceptions.
Parameters
\Symfony\Component\HttpKernel\Event\ExceptionEvent $event: The event to process.
File
-
core/
lib/ Drupal/ Core/ EventSubscriber/ ExceptionLoggingSubscriber.php, line 101
Class
- ExceptionLoggingSubscriber
- Log exceptions without further handling.
Namespace
Drupal\Core\EventSubscriberCode
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
$method = 'onError';
// Treat any non-HTTP exception as if it were one, so we log it the same.
if ($exception instanceof HttpExceptionInterface) {
$status_code = $exception->getStatusCode();
$possible_method = 'on' . $status_code;
if (method_exists($this, $possible_method)) {
$method = $possible_method;
}
elseif ($status_code >= 400 && $status_code < 500) {
$method = 'onClientError';
}
}
$this->{$method}($event);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.