4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
30 * Start of the Error framework. We should check out and inherit from
31 * PEAR_ErrorStack and use that framework
34 * @copyright CiviCRM LLC (c) 2004-2014
39 require_once 'PEAR/ErrorStack.php';
40 require_once 'PEAR/Exception.php';
41 require_once 'CRM/Core/Exception.php';
43 require_once 'Log.php';
48 class CRM_Exception
extends PEAR_Exception
{
49 // Redefine the exception so message isn't optional
51 * Supported signatures:
52 * - PEAR_Exception(string $message);
53 * - PEAR_Exception(string $message, int $code);
54 * - PEAR_Exception(string $message, Exception $cause);
55 * - PEAR_Exception(string $message, Exception $cause, int $code);
56 * - PEAR_Exception(string $message, PEAR_Error $cause);
57 * - PEAR_Exception(string $message, PEAR_Error $cause, int $code);
58 * - PEAR_Exception(string $message, array $causes);
59 * - PEAR_Exception(string $message, array $causes, int $code);
61 * @param string exception message
63 * @param Exception $previous
65 public function __construct($message = NULL, $code = 0, Exception
$previous = NULL) {
66 parent
::__construct($message, $code, $previous);
71 * Class CRM_Core_Error
73 class CRM_Core_Error
extends PEAR_ErrorStack
{
76 * Status code of various types of errors
79 const FATAL_ERROR
= 2;
80 const DUPLICATE_CONTACT
= 8001;
81 const DUPLICATE_CONTRIBUTION
= 8002;
82 const DUPLICATE_PARTICIPANT
= 8003;
85 * We only need one instance of this object. So we use the singleton
86 * pattern and cache the instance in this variable
90 private static $_singleton = NULL;
93 * The logger object for this application
97 private static $_log = NULL;
100 * If modeException == true, errors are raised as exception instead of returning civicrm_errors
103 public static $modeException = NULL;
106 * Singleton function used to manage this object.
108 * @param null $package
109 * @param bool $msgCallback
110 * @param bool $contextCallback
111 * @param bool $throwPEAR_Error
112 * @param string $stackClass
117 public static function &singleton($package = NULL, $msgCallback = FALSE, $contextCallback = FALSE, $throwPEAR_Error = FALSE, $stackClass = 'PEAR_ErrorStack') {
118 if (self
::$_singleton === NULL) {
119 self
::$_singleton = new CRM_Core_Error('CiviCRM');
121 return self
::$_singleton;
127 public function __construct() {
128 parent
::__construct('CiviCRM');
130 $log = CRM_Core_Config
::getLog();
131 $this->setLogger($log);
133 // set up error handling for Pear Error Stack
134 $this->setDefaultCallback(array($this, 'handlePES'));
139 * @param string $separator
141 * @return array|null|string
143 static public function getMessages(&$error, $separator = '<br />') {
144 if (is_a($error, 'CRM_Core_Error')) {
145 $errors = $error->getErrors();
147 foreach ($errors as $e) {
148 $message[] = $e['code'] . ': ' . $e['message'];
150 $message = implode($separator, $message);
157 * Status display function specific to payment processor errors
159 * @param string $separator
161 public static function displaySessionError(&$error, $separator = '<br />') {
162 $message = self
::getMessages($error, $separator);
164 $status = ts("Payment Processor Error message") . "{$separator} $message";
165 $session = CRM_Core_Session
::singleton();
166 $session->setStatus($status);
171 * Create the main callback method. this method centralizes error processing.
173 * the errors we expect are from the pear modules DB, DB_DataObject
174 * which currently use PEAR::raiseError to notify of error messages.
176 * @param object PEAR_Error
180 public static function handle($pearError) {
182 // setup smarty with config, session and template location.
183 $template = CRM_Core_Smarty
::singleton();
184 $config = CRM_Core_Config
::singleton();
186 if ($config->backtrace
) {
190 // create the error array
192 $error['callback'] = $pearError->getCallback();
193 $error['code'] = $pearError->getCode();
194 $error['message'] = $pearError->getMessage();
195 $error['mode'] = $pearError->getMode();
196 $error['debug_info'] = $pearError->getDebugInfo();
197 $error['type'] = $pearError->getType();
198 $error['user_info'] = $pearError->getUserInfo();
199 $error['to_string'] = $pearError->toString();
200 if (function_exists('mysql_error') &&
203 $mysql_error = mysql_error() . ', ' . mysql_errno();
204 $template->assign_by_ref('mysql_code', $mysql_error);
206 // execute a dummy query to clear error stack
207 mysql_query('select 1');
209 elseif (function_exists('mysqli_error')) {
210 $dao = new CRM_Core_DAO();
212 // we do it this way, since calling the function
213 // getDatabaseConnection could potentially result
214 // in an infinite loop
215 global $_DB_DATAOBJECT;
216 if (isset($_DB_DATAOBJECT['CONNECTIONS'][$dao->_database_dsn_md5
])) {
217 $conn = $_DB_DATAOBJECT['CONNECTIONS'][$dao->_database_dsn_md5
];
218 $link = $conn->connection
;
220 if (mysqli_error($link)) {
221 $mysql_error = mysqli_error($link) . ', ' . mysqli_errno($link);
222 $template->assign_by_ref('mysql_code', $mysql_error);
224 // execute a dummy query to clear error stack
225 mysqli_query($link, 'select 1');
230 $template->assign_by_ref('error', $error);
231 $errorDetails = CRM_Core_Error
::debug('', $error, FALSE);
232 $template->assign_by_ref('errorDetails', $errorDetails);
234 CRM_Core_Error
::debug_var('Fatal Error Details', $error);
235 CRM_Core_Error
::backtrace('backTrace', TRUE);
237 if ($config->initialized
) {
238 $content = $template->fetch('CRM/common/fatal.tpl');
239 echo CRM_Utils_System
::theme($content);
242 echo "Sorry. A non-recoverable error has occurred. The error trace below might help to resolve the issue<p>";
243 CRM_Core_Error
::debug(NULL, $error);
245 static $runOnce = FALSE;
253 // this function is used to trap and print errors
254 // during system initialization time. Hence the error
255 // message is quite ugly
259 public static function simpleHandler($pearError) {
261 // create the error array
263 $error['callback'] = $pearError->getCallback();
264 $error['code'] = $pearError->getCode();
265 $error['message'] = $pearError->getMessage();
266 $error['mode'] = $pearError->getMode();
267 $error['debug_info'] = $pearError->getDebugInfo();
268 $error['type'] = $pearError->getType();
269 $error['user_info'] = $pearError->getUserInfo();
270 $error['to_string'] = $pearError->toString();
272 // ensure that debug does not check permissions since we are in bootstrap
273 // mode and need to print a decent message to help the user
274 CRM_Core_Error
::debug('Initialization Error', $error, TRUE, TRUE, FALSE);
276 // always log the backtrace to a file
277 self
::backtrace('backTrace', TRUE);
283 * Handle errors raised using the PEAR Error Stack.
285 * currently the handler just requests the PES framework
286 * to push the error to the stack (return value PEAR_ERRORSTACK_PUSH).
288 * Note: we can do our own error handling here and return PEAR_ERRORSTACK_IGNORE.
290 * Also, if we do not return any value the PEAR_ErrorStack::push() then does the
291 * action of PEAR_ERRORSTACK_PUSHANDLOG which displays the errors on the screen,
292 * since the logger set for this error stack is 'display' - see CRM_Core_Config::getLog();
295 public static function handlePES($pearError) {
296 return PEAR_ERRORSTACK_PUSH
;
300 * Display an error page with an error message describing what happened
302 * @param string $message
304 * @param string $code
305 * The error code if any.
306 * @param string $email
307 * The email address to notify of this situation.
314 public static function fatal($message = NULL, $code = NULL, $email = NULL) {
316 'message' => $message,
320 if (self
::$modeException) {
322 CRM_Core_Error
::debug_var('Fatal Error Details', $vars);
323 CRM_Core_Error
::backtrace('backTrace', TRUE);
325 $details = 'A fatal error was triggered';
327 $details .= ': ' . $message;
329 throw new Exception($details, $code);
333 $message = ts('We experienced an unexpected error. Please post a detailed description and the backtrace on the CiviCRM forums: %1', array(1 => 'http://forum.civicrm.org/'));
336 if (php_sapi_name() == "cli") {
337 print ("Sorry. A non-recoverable error has occurred.\n$message \n$code\n$email\n\n");
338 debug_print_backtrace();
340 // FIXME: Why doesn't this call abend()?
341 // Difference: abend() will cleanup transaction and (via civiExit) store session state
342 // self::abend(CRM_Core_Error::FATAL_ERROR);
345 $config = CRM_Core_Config
::singleton();
347 if ($config->fatalErrorHandler
&&
348 function_exists($config->fatalErrorHandler
)
350 $name = $config->fatalErrorHandler
;
353 // the call has been successfully handled
355 self
::abend(CRM_Core_Error
::FATAL_ERROR
);
359 if ($config->backtrace
) {
363 CRM_Core_Error
::debug_var('Fatal Error Details', $vars);
364 CRM_Core_Error
::backtrace('backTrace', TRUE);
366 // If we are in an ajax callback, format output appropriately
367 if (CRM_Utils_Array
::value('snippet', $_REQUEST) === CRM_Core_Smarty
::PRINT_JSON
) {
370 'content' => '<div class="messages status no-popup"><div class="icon inform-icon"></div>' . ts('Sorry but we are not able to provide this at the moment.') . '</div>',
372 if ($config->backtrace
&& CRM_Core_Permission
::check('view debug output')) {
373 $out['backtrace'] = self
::parseBacktrace(debug_backtrace());
374 $message .= '<p><em>See console for backtrace</em></p>';
376 CRM_Core_Session
::setStatus($message, ts('Sorry an Error Occured'), 'error');
377 CRM_Core_Transaction
::forceRollbackIfEnabled();
378 CRM_Core_Page_AJAX
::returnJsonResponse($out);
381 $template = CRM_Core_Smarty
::singleton();
382 $template->assign($vars);
384 $config->userSystem
->outputError($template->fetch($config->fatalErrorTemplate
));
386 self
::abend(CRM_Core_Error
::FATAL_ERROR
);
390 * Display an error page with an error message describing what happened
392 * This function is evil -- it largely replicates fatal(). Hopefully the
393 * entire CRM_Core_Error system can be hollowed out and replaced with
394 * something that follows a cleaner separation of concerns.
396 * @param Exception $exception
401 public static function handleUnhandledException($exception) {
403 CRM_Utils_Hook
::unhandledException($exception);
405 catch (Exception
$other) {
406 // if the exception-handler generates an exception, then that sucks! oh, well. carry on.
407 CRM_Core_Error
::debug_var('handleUnhandledException_nestedException', self
::formatTextException($other));
409 $config = CRM_Core_Config
::singleton();
411 'message' => $exception->getMessage(),
413 'exception' => $exception,
415 if (!$vars['message']) {
416 $vars['message'] = ts('We experienced an unexpected error. Please post a detailed description and the backtrace on the CiviCRM forums: %1', array(1 => 'http://forum.civicrm.org/'));
420 if (php_sapi_name() == "cli") {
421 printf("Sorry. A non-recoverable error has occurred.\n%s\n", $vars['message']);
422 print self
::formatTextException($exception);
424 // FIXME: Why doesn't this call abend()?
425 // Difference: abend() will cleanup transaction and (via civiExit) store session state
426 // self::abend(CRM_Core_Error::FATAL_ERROR);
429 // Case B: Custom error handler
430 if ($config->fatalErrorHandler
&&
431 function_exists($config->fatalErrorHandler
)
433 $name = $config->fatalErrorHandler
;
436 // the call has been successfully handled
438 self
::abend(CRM_Core_Error
::FATAL_ERROR
);
442 // Case C: Default error handler
445 CRM_Core_Error
::debug_var('Fatal Error Details', $vars);
446 CRM_Core_Error
::backtrace('backTrace', TRUE);
449 $template = CRM_Core_Smarty
::singleton();
450 $template->assign($vars);
451 $content = $template->fetch($config->fatalErrorTemplate
);
452 if ($config->backtrace
) {
453 $content = self
::formatHtmlException($exception) . $content;
455 if ($config->userFramework
== 'Joomla' &&
456 class_exists('JError')
458 JError
::raiseError('CiviCRM-001', $content);
461 echo CRM_Utils_System
::theme($content);
465 self
::abend(CRM_Core_Error
::FATAL_ERROR
);
469 * Outputs pre-formatted debug information. Flushes the buffers
470 * so we can interrupt a potential POST/redirect
472 * @param string name of debug section
473 * @param mixed reference to variables that we need a trace of
474 * @param bool should we log or return the output
475 * @param bool whether to generate a HTML-escaped output
476 * @param bool should we check permissions before displaying output
477 * useful when we die during initialization and permissioning
478 * subsystem is not initialized - CRM-13765
480 * @return string the generated output
483 public static function debug($name, $variable = NULL, $log = TRUE, $html = TRUE, $checkPermission = TRUE) {
484 $error = self
::singleton();
486 if ($variable === NULL) {
491 $out = print_r($variable, TRUE);
494 $out = htmlspecialchars($out);
496 $prefix = "<p>$name</p>";
498 $out = "{$prefix}<p><pre>$out</pre></p><p></p>";
502 $prefix = "$name:\n";
504 $out = "{$prefix}$out\n";
508 (!$checkPermission || CRM_Core_Permission
::check('view debug output'))
517 * Similar to the function debug. Only difference is
518 * in the formatting of the output.
520 * @param string $variable_name
521 * @param mixed $variable
523 * Should we use print_r ? (else we use var_dump).
525 * Should we log or return the output.
526 * @param string $comp
529 * @return string the generated output
534 * @see CRM_Core_Error::debug()
535 * @see CRM_Core_Error::debug_log_message()
537 static function debug_var(
544 // check if variable is set
545 if (!isset($variable)) {
546 $out = "\$$variable_name is not set";
550 $out = print_r($variable, TRUE);
551 $out = "\$$variable_name = $out";
557 $dump = ob_get_contents();
559 $out = "\n\$$variable_name = $dump";
561 // reset if it is an array
562 if (is_array($variable)) {
566 return self
::debug_log_message($out, FALSE, $comp);
570 * Display the error message on terminal
574 * Should we log or return the output.
576 * @param string $comp
577 * Message to be output.
578 * @return string format of the backtrace
583 public static function debug_log_message($message, $out = FALSE, $comp = '') {
584 $config = CRM_Core_Config
::singleton();
586 $file_log = self
::createDebugLogger($comp);
587 $file_log->log("$message\n");
588 $str = "<p/><code>$message</code>";
589 if ($out && CRM_Core_Permission
::check('view debug output')) {
594 if ($config->userFrameworkLogging
) {
595 // should call $config->userSystem->logger($message) here - but I got a situation where userSystem was not an object - not sure why
596 if ($config->userSystem
->is_drupal
and function_exists('watchdog')) {
597 watchdog('civicrm', $message, NULL, WATCHDOG_DEBUG
);
605 * Append to the query log (if enabled)
607 public static function debug_query($string) {
608 if (defined('CIVICRM_DEBUG_LOG_QUERY')) {
609 if (CIVICRM_DEBUG_LOG_QUERY
== 'backtrace') {
610 CRM_Core_Error
::backtrace($string, TRUE);
612 elseif (CIVICRM_DEBUG_LOG_QUERY
) {
613 CRM_Core_Error
::debug_var('Query', $string, FALSE, TRUE);
619 * Execute a query and log the results.
621 * @param string $query
623 public static function debug_query_result($query) {
624 $dao = CRM_Core_DAO
::executeQuery($query);
626 while ($dao->fetch()) {
627 $results[] = (array) $dao;
629 CRM_Core_Error
::debug_var('dao result', array('query' => $query, 'results' => $results));
633 * Obtain a reference to the error log
635 * @param string $comp
639 public static function createDebugLogger($comp = '') {
640 $config = CRM_Core_Config
::singleton();
646 $fileName = "{$config->configAndLogDir}CiviCRM." . $comp . md5($config->dsn
) . '.log';
648 // Roll log file monthly or if greater than 256M
649 // note that PHP file functions have a limit of 2G and hence
650 // the alternative was introduce
651 if (file_exists($fileName)) {
652 $fileTime = date("Ym", filemtime($fileName));
653 $fileSize = filesize($fileName);
654 if (($fileTime < date('Ym')) ||
655 ($fileSize > 256 * 1024 * 1024) ||
659 $fileName . '.' . date('Ymdhs', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")))
664 return Log
::singleton('file', $fileName);
671 public static function backtrace($msg = 'backTrace', $log = FALSE) {
672 $backTrace = debug_backtrace();
673 $message = self
::formatBacktrace($backTrace);
675 CRM_Core_Error
::debug($msg, $message);
678 CRM_Core_Error
::debug_var($msg, $message);
683 * Render a backtrace array as a string
685 * @param array $backTrace
686 * Array of stack frames.
687 * @param bool $showArgs
688 * 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.
689 * @param int $maxArgLen
690 * Maximum number of characters to show from each argument string.
691 * @return string printable plain-text
693 public static function formatBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = 80) {
695 foreach (self
::parseBacktrace($backTrace, $showArgs, $maxArgLen) as $idx => $trace) {
696 $message .= sprintf("#%s %s\n", $idx, $trace);
698 $message .= sprintf("#%s {main}\n", 1 +
$idx);
703 * Render a backtrace array as an array
705 * @param array $backTrace
706 * Array of stack frames.
707 * @param bool $showArgs
708 * 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.
709 * @param int $maxArgLen
710 * Maximum number of characters to show from each argument string.
712 * @see debug_backtrace
713 * @see Exception::getTrace()
715 public static function parseBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = 80) {
717 foreach ($backTrace as $trace) {
719 $fnName = CRM_Utils_Array
::value('function', $trace);
720 $className = isset($trace['class']) ?
($trace['class'] . $trace['type']) : '';
722 // Do not show args for a few password related functions
723 $skipArgs = ($className == 'DB::' && $fnName == 'connect') ?
TRUE : FALSE;
725 if (!empty($trace['args'])) {
726 foreach ($trace['args'] as $arg) {
727 if (! $showArgs ||
$skipArgs) {
728 $args[] = '(' . gettype($arg) . ')';
731 switch ($type = gettype($arg)) {
733 $args[] = $arg ?
'TRUE' : 'FALSE';
742 $args[] = '"' . CRM_Utils_String
::ellipsify(addcslashes((string) $arg, "\r\n\t\""), $maxArgLen) . '"';
746 $args[] = '(Array:' . count($arg) . ')';
750 $args[] = 'Object(' . get_class($arg) . ')';
754 $args[] = 'Resource';
770 CRM_Utils_Array
::value('file', $trace, '[internal function]'),
771 CRM_Utils_Array
::value('line', $trace, ''),
781 * Render an exception as HTML string
783 * @param Exception $e
784 * @return string printable HTML text
786 public static function formatHtmlException(Exception
$e) {
789 // Exception metadata
791 // Exception backtrace
792 if ($e instanceof PEAR_Exception
) {
794 while (is_callable(array($ei, 'getCause'))) {
795 if ($ei->getCause() instanceof PEAR_Error
) {
796 $msg .= '<table class="crm-db-error">';
797 $msg .= sprintf('<thead><tr><th>%s</th><th>%s</th></tr></thead>', ts('Error Field'), ts('Error Value'));
799 foreach (array('Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo') as $f) {
800 $msg .= sprintf('<tr><td>%s</td><td>%s</td></tr>', $f, call_user_func(array($ei->getCause(), "get$f")));
802 $msg .= '</tbody></table>';
804 $ei = $ei->getCause();
806 $msg .= $e->toHtml();
809 $msg .= '<p><b>' . get_class($e) . ': "' . htmlentities($e->getMessage()) . '"</b></p>';
810 $msg .= '<pre>' . htmlentities(self
::formatBacktrace($e->getTrace())) . '</pre>';
816 * Write details of an exception to the log
818 * @param Exception $e
819 * @return string printable plain text
821 public static function formatTextException(Exception
$e) {
822 $msg = get_class($e) . ": \"" . $e->getMessage() . "\"\n";
825 while (is_callable(array($ei, 'getCause'))) {
826 if ($ei->getCause() instanceof PEAR_Error
) {
827 foreach (array('Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo') as $f) {
828 $msg .= sprintf(" * ERROR %s: %s\n", strtoupper($f), call_user_func(array($ei->getCause(), "get$f")));
831 $ei = $ei->getCause();
833 $msg .= self
::formatBacktrace($e->getTrace());
840 * @param string $level
841 * @param array $params
845 public static function createError($message, $code = 8000, $level = 'Fatal', $params = NULL) {
846 $error = CRM_Core_Error
::singleton();
847 $error->push($code, $level, array($params), $message);
852 * Set a status message in the session, then bounce back to the referrer.
854 * @param string $status
855 * The status message to set.
857 * @param null $redirect
858 * @param string $title
862 public static function statusBounce($status, $redirect = NULL, $title = NULL) {
863 $session = CRM_Core_Session
::singleton();
865 $redirect = $session->readUserContext();
867 if ($title === NULL) {
868 $title = ts('Error');
870 $session->setStatus($status, $title, 'alert', array('expires' => 0));
871 if (CRM_Utils_Array
::value('snippet', $_REQUEST) === CRM_Core_Smarty
::PRINT_JSON
) {
872 CRM_Core_Page_AJAX
::returnJsonResponse(array('status' => 'error'));
874 CRM_Utils_System
::redirect($redirect);
878 * Reset the error stack
882 public static function reset() {
883 $error = self
::singleton();
884 $error->_errors
= array();
885 $error->_errorsByLevel
= array();
889 * PEAR error-handler which converts errors to exceptions
892 * @throws PEAR_Exception
894 public static function exceptionHandler($pearError) {
895 CRM_Core_Error
::backtrace('backTrace', TRUE);
896 throw new PEAR_Exception($pearError->getMessage(), $pearError);
900 * PEAR error-handler to quietly catch otherwise fatal errors. Intended for use with smtp transport.
903 * The PEAR_ERROR object.
904 * @return object $obj
907 public static function nullHandler($obj) {
908 CRM_Core_Error
::debug_log_message("Ignoring exception thrown by nullHandler: {$obj->code}, {$obj->message}");
909 CRM_Core_Error
::backtrace('backTrace', TRUE);
915 * This function is no longer used by v3 api.
916 * @fixme Some core files call it but it should be re-thought & renamed or removed
925 public static function &createAPIError($msg, $data = NULL) {
926 if (self
::$modeException) {
927 throw new Exception($msg, $data);
932 $values['is_error'] = 1;
933 $values['error_message'] = $msg;
935 $values = array_merge($values, $data);
943 public static function movedSiteError($file) {
944 $url = CRM_Utils_System
::url('civicrm/admin/setting/updateConfigBackend',
948 echo "We could not write $file. Have you moved your site directory or server?<p>";
949 echo "Please fix the setting by running the <a href=\"$url\">update config script</a>";
954 * Terminate execution abnormally
956 protected static function abend($code) {
957 // do a hard rollback of any pending transactions
958 // if we've come here, its because of some unexpected PEAR errors
959 CRM_Core_Transaction
::forceRollbackIfEnabled();
960 CRM_Utils_System
::civiExit($code);
969 public static function isAPIError($error, $type = CRM_Core_Error
::FATAL_ERROR
) {
970 if (is_array($error) && !empty($error['is_error'])) {
971 $code = $error['error_message']['code'];
972 if ($code == $type) {
980 $e = new PEAR_ErrorStack('CRM');
981 $e->singleton('CRM', FALSE, NULL, 'CRM_Core_Error');