function _js_exception_handler in JS Callback Handler 7.2
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.
1 string reference to '_js_exception_handler'
- js_execute_request in ./
js.module - Loads the requested module and executes the requested callback.
File
- ./
js.module, line 516 - JavaScript callback handler module.
Code
function _js_exception_handler($exception) {
require_once DRUPAL_ROOT . '/includes/errors.inc';
// Support both PHP 5 exceptions and PHP 7 throwables.
// @see https://www.drupal.org/project/js/issues/3027913
try {
_js_log_php_error(_drupal_decode_exception($exception), TRUE);
} catch (\Throwable $uncaught) {
// Intentionally left blank.
} catch (\Exception $uncaught) {
// Intentionally left blank.
}
// Another uncaught exception was thrown while handling the first one.
// If we are displaying errors, then do so with no possibility of a further
// uncaught exception being thrown.
if (isset($uncaught)) {
$message = '<h1>Additional uncaught exception thrown while handling exception.</h1>';
$message .= '<h2>Original</h2><p>' . _drupal_render_exception_safe($exception) . '</p>';
$message .= '<h2>Additional</h2><p>' . _drupal_render_exception_safe($uncaught) . '</p>';
$backtrace = debug_backtrace();
$caller = _drupal_get_last_caller($backtrace);
_js_log_php_error(array(
'%type' => 'Unknown error',
// The standard PHP error handler considers that the error messages
// are HTML. Mimic this behavior here.
'!message' => filter_xss_admin($message),
'%function' => $caller['function'],
'%file' => $caller['file'],
'%line' => $caller['line'],
'severity_level' => WATCHDOG_ERROR,
), TRUE);
}
}