function _drupal_decode_exception

cis7 errors.inc _drupal_decode_exception($exception)
cle7 errors.inc _drupal_decode_exception($exception)
elmsmedia7 errors.inc _drupal_decode_exception($exception)
icor7 errors.inc _drupal_decode_exception($exception)
meedjum_blog7 errors.inc _drupal_decode_exception($exception)
mooc7 errors.inc _drupal_decode_exception($exception)

Decodes an exception and retrieves the correct caller.

Parameters

$exception: The exception object that was thrown.

Return value

An error in the format expected by _drupal_log_error().

5 calls to _drupal_decode_exception()
DrupalTestCase::exceptionHandler in modules/simpletest/drupal_web_test_case.php
Handle exceptions.
update_do_one in includes/update.inc
Performs one update and stores the results for display on the results page.
watchdog_exception in includes/bootstrap.inc
Logs an exception.
_drupal_exception_handler in includes/bootstrap.inc
Provides custom PHP exception handling.
_drupal_render_exception_safe in includes/errors.inc
Renders an exception error message without further exceptions.

File

includes/errors.inc, line 88
Functions for error handling.

Code

function _drupal_decode_exception($exception) {
  $message = $exception->getMessage();

  $backtrace = $exception->getTrace();
  // Add the line throwing the exception to the backtrace.
  array_unshift($backtrace, array('line' => $exception->getLine(), 'file' => $exception->getFile()));

  // For PDOException errors, we try to return the initial caller,
  // skipping internal functions of the database layer.
  if ($exception instanceof PDOException) {
    // The first element in the stack is the call, the second element gives us the caller.
    // We skip calls that occurred in one of the classes of the database layer
    // or in one of its global functions.
    $db_functions = array('db_query', 'db_query_range');
    while (!empty($backtrace[1]) && ($caller = $backtrace[1]) && ((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) || in_array($caller['function'], $db_functions))) {
      // We remove that call.
      array_shift($backtrace);
    }
    if (isset($exception->query_string, $exception->args)) {
      $message .= ": " . $exception->query_string . "; " . print_r($exception->args, TRUE);
    }
  }
  $caller = _drupal_get_last_caller($backtrace);

  return array(
    '%type' => get_class($exception),
    
    // The standard PHP exception handler considers that the exception message
    // is plain-text. We mimick this behavior here.
    '!message' => check_plain($message),
    '%function' => $caller['function'],
    '%file' => $caller['file'],
    '%line' => $caller['line'],
    'severity_level' => WATCHDOG_ERROR,
  );
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.