/** Print database error message * * @param object $msg Database error object */ function dbError($msg) { $debug = $msg->getDebugInfo(); if (preg_match("/Unknown column 'zone_templ_id'/", $debug)) { $debug = ERR_DB_NO_DB_UPDATE; } echo " <div class=\"error\">Error: " . $debug . "</div>\n"; include_once "footer.inc.php"; die; }
/** * This function raises the error as a callback function for views. * * @access public * @author Kalmer Piiskop <*****@*****.**> * @param object $errorFromOutside * the error object */ public static function raiseError($errorFromOutside) { require_once 'HTML/Template/IT.php'; $template = new \HTML_Template_IT(ROOT_FOLDER . '../html'); $template->loadTemplateFile('errors.html'); $template->setCurrentBlock('html'); $template->setVariable(array('TITLE-OF-ERROR' => \pstk\String::translate('titleOfError'), 'MESSAGE' => $errorFromOutside->getMessage(), 'DEBUG-INFO' => $errorFromOutside->getDebugInfo())); $template->parse('html'); exit($template->get('html')); }
/** * Create the main callback method. this method centralizes error processing. * * the errors we expect are from the pear modules DB, DB_DataObject * which currently use PEAR::raiseError to notify of error messages. * * @param object $pearError PEAR_Error * * @return void */ public static function handle($pearError) { // setup smarty with config, session and template location. $template = CRM_Core_Smarty::singleton(); $config = CRM_Core_Config::singleton(); if ($config->backtrace) { self::backtrace(); } // create the error array $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(); // We access connection info via _DB_DATAOBJECT instead // of, e.g., calling getDatabaseConnection(), so that we // can avoid infinite loops. global $_DB_DATAOBJECT; if (!isset($_DB_DATAOBJECT['CONFIG']['database'])) { // we haven't setup sql, so it's not our sql error... } elseif (preg_match('/^mysql:/', $_DB_DATAOBJECT['CONFIG']['database']) && mysql_error()) { $mysql_error = mysql_error() . ', ' . mysql_errno(); $template->assign_by_ref('mysql_code', $mysql_error); // execute a dummy query to clear error stack mysql_query('select 1'); } elseif (preg_match('/^mysqli:/', $_DB_DATAOBJECT['CONFIG']['database'])) { $dao = new CRM_Core_DAO(); if (isset($_DB_DATAOBJECT['CONNECTIONS'][$dao->_database_dsn_md5])) { $conn = $_DB_DATAOBJECT['CONNECTIONS'][$dao->_database_dsn_md5]; $link = $conn->connection; if (mysqli_error($link)) { $mysql_error = mysqli_error($link) . ', ' . mysqli_errno($link); $template->assign_by_ref('mysql_code', $mysql_error); // execute a dummy query to clear error stack mysqli_query($link, 'select 1'); } } } $template->assign_by_ref('error', $error); $errorDetails = CRM_Core_Error::debug('', $error, FALSE); $template->assign_by_ref('errorDetails', $errorDetails); CRM_Core_Error::debug_var('Fatal Error Details', $error); CRM_Core_Error::backtrace('backTrace', TRUE); if ($config->initialized) { $content = $template->fetch('CRM/common/fatal.tpl'); echo CRM_Utils_System::theme($content); } else { echo "Sorry. A non-recoverable error has occurred. The error trace below might help to resolve the issue<p>"; CRM_Core_Error::debug(NULL, $error); } static $runOnce = FALSE; if ($runOnce) { exit; } $runOnce = TRUE; self::abend(1); }
/** * Handles the PEAR_Error object returned from the SMTP server, and returns * an appropriate error message string. * * @access private * @param object $error The PEAR_Error object * @return string The error message */ function _getErrorMessage($error) { return $error->getMessage() . "/" . $error->getDebugInfo(); }
/** * This function raises the error as a callback function for views. * * @access public * @author Kalmer Piiskop * @param object $errorFromOutside * the error object */ public static function raiseError($errorFromOutside) { echo ' 25: ', $errorFromOutside->getDebugInfo(); echo ' 26: ', $errorFromOutside->getMessage(); exit; }