本文整理汇总了PHP中CRM_Core_Error::formatTextException方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Error::formatTextException方法的具体用法?PHP CRM_Core_Error::formatTextException怎么用?PHP CRM_Core_Error::formatTextException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Error
的用法示例。
在下文中一共展示了CRM_Core_Error::formatTextException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Perform an upgrade without using the web-frontend
*
* @param bool $enablePrint
*
* @throws Exception
* @return array, with keys:
* - message: string, HTML-ish blob
*/
public function run($enablePrint = TRUE)
{
// lets get around the time limit issue if possible for upgrades
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
$upgrade = new CRM_Upgrade_Form();
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
throw new Exception($error);
}
// Disable our SQL triggers
CRM_Core_DAO::dropTriggers();
// CRM-11156
$preUpgradeMessage = NULL;
$upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
$postUpgradeMessageFile = CRM_Utils_File::tempnam('civicrm-post-upgrade');
$queueRunner = new CRM_Queue_Runner(array('title' => ts('CiviCRM Upgrade Tasks'), 'queue' => CRM_Upgrade_Form::buildQueue($currentVer, $latestVer, $postUpgradeMessageFile)));
$queueResult = $queueRunner->runAll();
if ($queueResult !== TRUE) {
$errorMessage = CRM_Core_Error::formatTextException($queueResult['exception']);
CRM_Core_Error::debug_log_message($errorMessage);
if ($enablePrint) {
print $errorMessage;
}
throw $queueResult['exception'];
// FIXME test
}
CRM_Upgrade_Form::doFinish();
$message = file_get_contents($postUpgradeMessageFile);
return array('latestVer' => $latestVer, 'message' => $message, 'text' => CRM_Utils_String::htmlToText($message));
}
示例2: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
*/
public function log($level, $message, array $context = array())
{
// FIXME: This flattens a $context a bit prematurely. When integrating
// with external/CMS logs, we should pass through $context.
if (!empty($context)) {
if (isset($context['exception'])) {
$context['exception'] = CRM_Core_Error::formatTextException($context['exception']);
}
$message .= "\n" . print_r($context, 1);
}
CRM_Core_Error::debug_log_message($message, FALSE, '', $this->map[$level]);
}
示例3: reportException
/**
* Print an unhandled exception
*
* @param $e
*/
function reportException(Exception $e)
{
CRM_Core_Error::debug_var('CRM_Queue_ErrorPolicy_reportException', CRM_Core_Error::formatTextException($e));
$response = array('is_error' => 1, 'is_continue' => 0);
$config = CRM_Core_Config::singleton();
if ($config->backtrace || CRM_Core_Config::isUpgradeMode()) {
$response['exception'] = CRM_Core_Error::formatHtmlException($e);
} else {
$response['exception'] = htmlentities($e->getMessage());
}
global $activeQueueRunner;
if (is_object($activeQueueRunner)) {
$response['last_task_title'] = $activeQueueRunner->lastTaskTitle;
}
CRM_Utils_JSON::output($response);
}
示例4: _return
/**
* Performing any view-layer filtering on result and send to client.
*/
static function _return($op, $result)
{
if ($result['is_error']) {
if (is_object($result['exception'])) {
CRM_Core_Error::debug_var("CRM_Queue_Page_AJAX_{$op}_error", CRM_Core_Error::formatTextException($result['exception']));
$config = CRM_Core_Config::singleton();
if ($config->backtrace || CRM_Core_Config::isUpgradeMode()) {
$result['exception'] = CRM_Core_Error::formatHtmlException($result['exception']);
} else {
$result['exception'] = $result['exception']->getMessage();
}
} else {
CRM_Core_Error::debug_var("CRM_Queue_Page_AJAX_{$op}_error", $result);
}
}
CRM_Utils_JSON::output($result);
}
示例5: runTest
/**
* Override to run the test and assert its state.
* @return mixed
* @throws \Exception
* @throws \PHPUnit_Framework_IncompleteTest
* @throws \PHPUnit_Framework_SkippedTest
*/
protected function runTest()
{
try {
return parent::runTest();
} catch (PEAR_Exception $e) {
// PEAR_Exception has metadata in funny places, and PHPUnit won't log it nicely
throw new Exception(\CRM_Core_Error::formatTextException($e), $e->getCode());
}
}