* - PEAR_Exception(string $message, PEAR_Error $cause, int $code);
* - PEAR_Exception(string $message, array $causes);
* - PEAR_Exception(string $message, array $causes, int $code);
+ *
* @param string exception message
- * @param int|Exception|PEAR_Error|array|null exception cause
- * @param int|null exception code or null
+ * @param int $code
+ * @param Exception $previous
+ *
+ * @internal param array|\Exception|int|null|\PEAR_Error $exception cause
+ * @internal param int|null $exception code or null
*/
public function __construct($message = NULL, $code = 0, Exception$previous = NULL) {
parent::__construct($message, $code, $previous);
}
}
+/**
+ * Class CRM_Core_Error
+ */
class CRM_Core_Error extends PEAR_ErrorStack {
/**
}
/**
- * construcor
+ * constructor
*/
function __construct() {
parent::__construct('CiviCRM');
$this->setDefaultCallback(array($this, 'handlePES'));
}
+ /**
+ * @param $error
+ * @param string $separator
+ *
+ * @return array|null|string
+ */
static public function getMessages(&$error, $separator = '<br />') {
if (is_a($error, 'CRM_Core_Error')) {
$errors = $error->getErrors();
// 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
CRM_Core_Error::debug_var('Fatal Error Details', $vars);
CRM_Core_Error::backtrace('backTrace', TRUE);
- $content = $template->fetch($config->fatalErrorTemplate);
- // JErrorPage exists only in 3.x and not 2.x
- // CRM-13714
- if ($config->userFramework == 'Joomla' && class_exists('JErrorPage')) {
- $error = new Exception($content);
- JErrorPage::render($error);
- }
- else if ($config->userFramework == 'Joomla' && class_exists('JError')) {
- JError::raiseError('CiviCRM-001', $content);
- }
- else {
- echo CRM_Utils_System::theme($content);
- }
+ $config->userSystem->outputError($template->fetch($config->fatalErrorTemplate));
self::abend(CRM_Core_Error::FATAL_ERROR);
}
$file_log->close();
if ($config->userFrameworkLogging) {
+ // should call $config->userSystem->logger($message) here - but I got a situation where userSystem was not an object - not sure why
if ($config->userSystem->is_drupal and function_exists('watchdog')) {
- watchdog('civicrm', $message, NULL, WATCHDOG_DEBUG);
+ watchdog('civicrm', '%message', array('%message' => $message), WATCHDOG_DEBUG);
}
}
return Log::singleton('file', $fileName);
}
+ /**
+ * @param string $msg
+ * @param bool $log
+ */
static function backtrace($msg = 'backTrace', $log = FALSE) {
$backTrace = debug_backtrace();
$message = self::formatBacktrace($backTrace);
$fnName = CRM_Utils_Array::value('function', $trace);
$className = isset($trace['class']) ? ($trace['class'] . $trace['type']) : '';
- // do now show args for a few password related functions
+ // Do not show args for a few password related functions
$skipArgs = ($className == 'DB::' && $fnName == 'connect') ? TRUE : FALSE;
- foreach ($trace['args'] as $arg) {
- if (! $showArgs || $skipArgs) {
- $args[] = '(' . gettype($arg) . ')';
- continue;
- }
- switch ($type = gettype($arg)) {
- case 'boolean':
- $args[] = $arg ? 'TRUE' : 'FALSE';
- break;
- case 'integer':
- case 'double':
- $args[] = $arg;
- break;
- case 'string':
- $args[] = '"' . CRM_Utils_String::ellipsify(addcslashes((string) $arg, "\r\n\t\""), $maxArgLen). '"';
- break;
- case 'array':
- $args[] = '(Array:'.count($arg).')';
- break;
- case 'object':
- $args[] = 'Object(' . get_class($arg) . ')';
- break;
- case 'resource':
- $args[] = 'Resource';
- break;
- case 'NULL':
- $args[] = 'NULL';
- break;
- default:
- $args[] = "($type)";
- break;
+ if (!empty($trace['args'])) {
+ foreach ($trace['args'] as $arg) {
+ if (! $showArgs || $skipArgs) {
+ $args[] = '(' . gettype($arg) . ')';
+ continue;
+ }
+ switch ($type = gettype($arg)) {
+ case 'boolean':
+ $args[] = $arg ? 'TRUE' : 'FALSE';
+ break;
+ case 'integer':
+ case 'double':
+ $args[] = $arg;
+ break;
+ case 'string':
+ $args[] = '"' . CRM_Utils_String::ellipsify(addcslashes((string) $arg, "\r\n\t\""), $maxArgLen). '"';
+ break;
+ case 'array':
+ $args[] = '(Array:'.count($arg).')';
+ break;
+ case 'object':
+ $args[] = 'Object(' . get_class($arg) . ')';
+ break;
+ case 'resource':
+ $args[] = 'Resource';
+ break;
+ case 'NULL':
+ $args[] = 'NULL';
+ break;
+ default:
+ $args[] = "($type)";
+ break;
+ }
}
}
return $msg;
}
+ /**
+ * @param $message
+ * @param int $code
+ * @param string $level
+ * @param null $params
+ *
+ * @return object
+ */
static function createError($message, $code = 8000, $level = 'Fatal', $params = NULL) {
$error = CRM_Core_Error::singleton();
$error->push($code, $level, array($params), $message);
* @access public
* @static
*/
- public static function statusBounce($status, $redirect = NULL, $title = '') {
+ public static function statusBounce($status, $redirect = NULL, $title = NULL) {
$session = CRM_Core_Session::singleton();
if (!$redirect) {
$redirect = $session->readUserContext();
}
- $session->setStatus($status, $title);
+ if ($title === NULL) {
+ $title = ts('Error');
+ }
+ $session->setStatus($status, $title, 'alert', array('expires' => 0));
if (CRM_Utils_Array::value('snippet', $_REQUEST) === CRM_Core_Smarty::PRINT_JSON) {
CRM_Core_Page_AJAX::returnJsonResponse(array('status' => 'error'));
}
* 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
+ *
+ * @return array
+ * @throws Exception
+ */
public static function &createAPIError($msg, $data = NULL) {
if (self::$modeException) {
throw new Exception($msg, $data);
return $values;
}
+ /**
+ * @param $file
+ */
public static function movedSiteError($file) {
$url = CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend',
'reset=1',
CRM_Utils_System::civiExit($code);
}
+ /**
+ * @param $error
+ * @param const $type
+ *
+ * @return bool
+ */
public static function isAPIError($error, $type = CRM_Core_Error::FATAL_ERROR) {
if (is_array($error) && !empty($error['is_error'])) {
$code = $error['error_message']['code'];