You are here

function _js_log_php_error in JS Callback Handler 7.2

Logs a PHP error or exception and displays the error in fatal cases.

Parameters

array $error: An array with the following keys: %type, !message, %function, %file, %line and severity_level. All the parameters are plain-text, with the exception of !message, which needs to be a safe HTML string.

bool $fatal: TRUE if the error is fatal.

3 calls to _js_log_php_error()
_js_error_handler in ./js.module
Provides custom PHP error handling.
_js_exception_handler in ./js.module
Provides custom PHP exception handling.
_js_fatal_error_handler in ./js.module
Provides custom PHP fatal error handling.

File

./js.module, line 581
JavaScript callback handler module.

Code

function _js_log_php_error(array $error, $fatal = FALSE) {

  // Log the error immediately.
  watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);

  // Display the error to the user, if it should.
  if (error_displayable($error)) {
    if (!isset($error['%function'])) {
      drupal_set_message(t('%type: !message (line %line of %file).', $error), 'error');
    }
    else {
      drupal_set_message(t('%type: !message in %function (line %line of %file).', $error), 'error');
    }
  }

  // If fatal, deliver an internal server error response.
  if ($fatal) {
    js_deliver(js_http_response(500));
  }
}