You are here

function _drupal_exception_handler in Drupal 10

Same name and namespace in other branches
  1. 8 core/includes/bootstrap.inc \_drupal_exception_handler()
  2. 7 includes/bootstrap.inc \_drupal_exception_handler()
  3. 9 core/includes/bootstrap.inc \_drupal_exception_handler()

Provides custom PHP exception handling.

Uncaught exceptions are those not enclosed in a try/catch block. They are always fatal: the execution of the script will stop as soon as the exception handler exits.

Parameters

\Exception|\Throwable $exception: The exception object that was thrown.

4 string references to '_drupal_exception_handler'
DrupalKernel::bootEnvironment in core/lib/Drupal/Core/DrupalKernel.php
Setup a consistent PHP environment.
drupal_rebuild in core/includes/utility.inc
Rebuilds all caches even when Drupal itself does not work.
Error.php in core/lib/Drupal/Core/Utility/Error.php
ErrorTest::providerTestGetLastCaller in core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
Data provider for testGetLastCaller.

File

core/includes/bootstrap.inc, line 171
Functions that need to be loaded on every Drupal request.

Code

function _drupal_exception_handler($exception) {
  require_once __DIR__ . '/errors.inc';
  try {

    // Log the message to the watchdog and return an error page to the user.
    _drupal_log_error(Error::decodeException($exception), TRUE);
  } catch (\Throwable $error) {
    _drupal_exception_handler_additional($exception, $error);
  }
}