You are here

public static function cf_error::on_exception in Common Functionality 7.2

Reports php exceptions.

@see: watchdog() @see: watchdog_severity_levels()

Parameters

object $exception: The query exception object.

int $severity: (optional) The severity of the message, as per RFC 3164. Possible values are WATCHDOG_ERROR, WATCHDOG_WARNING, etc.

Return value

cf_error_code A object containing the processed error, with specified backtrace.

File

modules/cf_error/classes/cf_error.php, line 499
Provides the derror exception class.

Class

cf_error

Code

public static function on_exception($exception, $severity = WATCHDOG_ERROR) {
  $error = new cf_error_code();
  if (is_object($exception)) {
    $exception_message = $exception
      ->getMessage();
  }
  else {
    if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
      $backtrace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, self::p_backtrace_limit());
    }
    else {
      $backtrace = debug_backtrace();
    }
    self::p_report_invalid_argument_object('exception', $backtrace);
    unset($backtrace);
    $exception_message = "";
  }
  $error
    ->set_severity($severity);
  $error
    ->set_type('php');
  self::p_load_backtrace($error);
  self::p_on_exception($error, $exception_message);
  return $error;
}