<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
* Start of the Error framework. We should check out and inherit from
* Class CRM_Exception
*/
class CRM_Exception extends PEAR_Exception {
- // Redefine the exception so message isn't optional
/**
+ * Redefine the exception so message isn't optional
* Supported signatures:
* - PEAR_Exception(string $message);
* - PEAR_Exception(string $message, int $code);
* - PEAR_Exception(string $message, array $causes);
* - PEAR_Exception(string $message, array $causes, int $code);
*
- * @param string exception message
+ * @param string $message exception message
* @param int $code
* @param Exception $previous
*/
- public function __construct($message = NULL, $code = 0, Exception$previous = NULL) {
+ public function __construct($message = NULL, $code = 0, Exception $previous = NULL) {
parent::__construct($message, $code, $previous);
}
+
}
/**
/**
* Status code of various types of errors
- * @var const
*/
const FATAL_ERROR = 2;
const DUPLICATE_CONTACT = 8001;
* We only need one instance of this object. So we use the singleton
* pattern and cache the instance in this variable
* @var object
- * @static
*/
private static $_singleton = NULL;
/**
* The logger object for this application
* @var object
- * @static
*/
private static $_log = NULL;
/**
* If modeException == true, errors are raised as exception instead of returning civicrm_errors
- * @static
*/
public static $modeException = NULL;
* @param string $stackClass
*
* @return object
- * @static
*/
public static function &singleton($package = NULL, $msgCallback = FALSE, $contextCallback = FALSE, $throwPEAR_Error = FALSE, $stackClass = 'PEAR_ErrorStack') {
if (self::$_singleton === NULL) {
* the errors we expect are from the pear modules DB, DB_DataObject
* which currently use PEAR::raiseError to notify of error messages.
*
- * @param object PEAR_Error
+ * @param object $pearError PEAR_Error
*
* @return void
*/
}
// create the error array
- $error = array();
- $error['callback'] = $pearError->getCallback();
- $error['code'] = $pearError->getCode();
- $error['message'] = $pearError->getMessage();
- $error['mode'] = $pearError->getMode();
+ $error = array();
+ $error['callback'] = $pearError->getCallback();
+ $error['code'] = $pearError->getCode();
+ $error['message'] = $pearError->getMessage();
+ $error['mode'] = $pearError->getMode();
$error['debug_info'] = $pearError->getDebugInfo();
- $error['type'] = $pearError->getType();
- $error['user_info'] = $pearError->getUserInfo();
- $error['to_string'] = $pearError->toString();
+ $error['type'] = $pearError->getType();
+ $error['user_info'] = $pearError->getUserInfo();
+ $error['to_string'] = $pearError->toString();
if (function_exists('mysql_error') &&
mysql_error()
) {
self::abend(1);
}
- // this function is used to trap and print errors
- // during system initialization time. Hence the error
- // message is quite ugly
/**
+ * this function is used to trap and print errors
+ * during system initialization time. Hence the error
+ * message is quite ugly
+ *
* @param $pearError
*/
public static function simpleHandler($pearError) {
// create the error array
- $error = array();
- $error['callback'] = $pearError->getCallback();
- $error['code'] = $pearError->getCode();
- $error['message'] = $pearError->getMessage();
- $error['mode'] = $pearError->getMode();
+ $error = array();
+ $error['callback'] = $pearError->getCallback();
+ $error['code'] = $pearError->getCode();
+ $error['message'] = $pearError->getMessage();
+ $error['mode'] = $pearError->getMode();
$error['debug_info'] = $pearError->getDebugInfo();
- $error['type'] = $pearError->getType();
- $error['user_info'] = $pearError->getUserInfo();
- $error['to_string'] = $pearError->toString();
+ $error['type'] = $pearError->getType();
+ $error['user_info'] = $pearError->getUserInfo();
+ $error['to_string'] = $pearError->toString();
// ensure that debug does not check permissions since we are in bootstrap
// mode and need to print a decent message to help the user
* Also, if we do not return any value the PEAR_ErrorStack::push() then does the
* action of PEAR_ERRORSTACK_PUSHANDLOG which displays the errors on the screen,
* since the logger set for this error stack is 'display' - see CRM_Core_Config::getLog();
- *
*/
public static function handlePES($pearError) {
return PEAR_ERRORSTACK_PUSH;
* @throws Exception
*
* @return void
- * @static
*/
public static function fatal($message = NULL, $code = NULL, $email = NULL) {
$vars = array(
* @param Exception $exception
*
* @return void
- * @static
*/
public static function handleUnhandledException($exception) {
try {
* Outputs pre-formatted debug information. Flushes the buffers
* so we can interrupt a potential POST/redirect
*
- * @param string name of debug section
- * @param mixed reference to variables that we need a trace of
- * @param bool should we log or return the output
- * @param bool whether to generate a HTML-escaped output
- * @param bool should we check permissions before displaying output
+ * @param string $name name of debug section
+ * @param $variable mixed reference to variables that we need a trace of
+ * @param bool $log should we log or return the output
+ * @param bool $html whether to generate a HTML-escaped output
+ * @param bool $checkPermission should we check permissions before displaying output
* useful when we die during initialization and permissioning
* subsystem is not initialized - CRM-13765
*
- * @return string the generated output
- * @static
+ * @return string
+ * the generated output
*/
public static function debug($name, $variable = NULL, $log = TRUE, $html = TRUE, $checkPermission = TRUE) {
$error = self::singleton();
* @param string $comp
* Variable name.
*
- * @return string the generated output
+ * @return string
+ * the generated output
*
*
- * @static
*
* @see CRM_Core_Error::debug()
* @see CRM_Core_Error::debug_log_message()
*/
- static function debug_var(
+ public static function debug_var(
$variable_name,
$variable,
$print = TRUE,
*
* @param string $comp
* Message to be output.
- * @return string format of the backtrace
+ * @return string
+ * format of the backtrace
*
*
- * @static
*/
public static function debug_log_message($message, $out = FALSE, $comp = '') {
$config = CRM_Core_Config::singleton();
* TRUE if we should try to display content of function arguments (which could be sensitive); FALSE to display only the type of each function argument.
* @param int $maxArgLen
* Maximum number of characters to show from each argument string.
- * @return string printable plain-text
+ * @return string
+ * printable plain-text
*/
public static function formatBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = 80) {
$message = '';
if (!empty($trace['args'])) {
foreach ($trace['args'] as $arg) {
- if (! $showArgs || $skipArgs) {
+ if (!$showArgs || $skipArgs) {
$args[] = '(' . gettype($arg) . ')';
continue;
}
* Render an exception as HTML string
*
* @param Exception $e
- * @return string printable HTML text
+ * @return string
+ * printable HTML text
*/
public static function formatHtmlException(Exception $e) {
$msg = '';
* Write details of an exception to the log
*
* @param Exception $e
- * @return string printable plain text
+ * @return string
+ * printable plain text
*/
public static function formatTextException(Exception $e) {
$msg = get_class($e) . ": \"" . $e->getMessage() . "\"\n";
* @param null $redirect
* @param string $title
* @return void
- * @static
*/
public static function statusBounce($status, $redirect = NULL, $title = NULL) {
$session = CRM_Core_Session::singleton();
/**
* Reset the error stack
*
- * @static
*/
public static function reset() {
$error = self::singleton();
*
* @param object $obj
* The PEAR_ERROR object.
- * @return object $obj
- * @static
+ * @return object
+ * $obj
*/
public static function nullHandler($obj) {
CRM_Core_Error::debug_log_message("Ignoring exception thrown by nullHandler: {$obj->code}, {$obj->message}");
return $obj;
}
- /*
+ /**
* @deprecated
* This function is no longer used by v3 api.
* @fixme Some core files call it but it should be re-thought & renamed or removed
- */
- /**
+ *
* @param $msg
* @param null $data
*
}
/**
- * @param $error
- * @param const $type
+ * @param array $error
+ * @param int $type
*
* @return bool
*/
}
return FALSE;
}
+
}
$e = new PEAR_ErrorStack('CRM');