本文整理汇总了PHP中PEAR_Error::getBacktrace方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Error::getBacktrace方法的具体用法?PHP PEAR_Error::getBacktrace怎么用?PHP PEAR_Error::getBacktrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Error
的用法示例。
在下文中一共展示了PEAR_Error::getBacktrace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: errorObjToString
/**
* A method to convert PEAR_Error objects to strings.
*
* @static
* @param PEAR_Error $oError A {@link PEAR_Error} object
*/
function errorObjToString($oError, $additionalInfo = null)
{
$aConf = $GLOBALS['_MAX']['CONF'];
$message = htmlspecialchars($oError->getMessage());
$debugInfo = htmlspecialchars($oError->getDebugInfo());
$backtrace = htmlspecialchars($oError->getBacktrace());
$additionalInfo = htmlspecialchars($additionalInfo);
$level = $oError->getCode();
$errorType = MAX::errorConstantToString($level);
$img = MAX::constructURL(MAX_URL_IMAGE, 'errormessage.gif');
// Message
$output = <<<EOF
<br />
<div class="errormessage">
<img class="errormessage" src="{$img}" align="absmiddle">
<span class='tab-r'>{$errorType} Error</span>
<br />
<br />{$message}
<br /><pre>{$debugInfo}</pre>
{$additionalInfo}
</div>
<br />
<br />
EOF;
return $output;
}
示例2: _getPearTrace
/**
* Return a trace for the PEAR error.
*
* @param PEAR_Error $error The PEAR error.
*
* @return string The backtrace as a string.
*/
private function _getPearTrace(PEAR_Error $error)
{
$backtrace = $error->getBacktrace();
if (!empty($backtrace)) {
$pear_error = "\n\n" . 'PEAR Error:' . "\n";
foreach ($backtrace as $frame) {
$pear_error .= ' ' . (isset($frame['class']) ? $frame['class'] : '') . (isset($frame['type']) ? $frame['type'] : '') . (isset($frame['function']) ? $frame['function'] : 'unkown') . ' ' . (isset($frame['file']) ? $frame['file'] : 'unkown') . ':' . (isset($frame['line']) ? $frame['line'] : 'unkown') . "\n";
}
$pear_error .= "\n";
return $pear_error;
}
return '';
}
示例3: __construct
/**
* @param PEAR_Error $error
*/
public function __construct(PEAR_Error $error)
{
$message = $error->getMessage();
$userInfo = $error->getUserInfo();
if (!is_null($userInfo)) {
$message .= ', ' . $userInfo;
}
parent::__construct($message);
$backtrace = $error->getBacktrace();
if (is_array($backtrace)) {
$this->file = $backtrace[1]['file'];
$this->line = $backtrace[1]['line'];
}
}
示例4: _getPearTrace
/**
* Return a trace for the PEAR error.
*
* @param PEAR_Error $error The PEAR error.
*
* @return string The backtrace as a string.
*/
private function _getPearTrace(PEAR_Error $error)
{
$pear_error = '';
$backtrace = $error->getBacktrace();
if (!empty($backtrace)) {
$pear_error .= 'PEAR backtrace:' . "\n\n";
foreach ($backtrace as $frame) {
$pear_error .= (isset($frame['class']) ? $frame['class'] : '') . (isset($frame['type']) ? $frame['type'] : '') . (isset($frame['function']) ? $frame['function'] : 'unkown') . ' ' . (isset($frame['file']) ? $frame['file'] : 'unkown') . ':' . (isset($frame['line']) ? $frame['line'] : 'unkown') . "\n";
}
}
$userinfo = $error->getUserInfo();
if (!empty($userinfo)) {
$pear_error .= "\n" . 'PEAR user info:' . "\n\n";
if (is_string($userinfo)) {
$pear_error .= $userinfo;
} else {
$pear_error .= print_r($userinfo, true);
}
}
return $pear_error;
}
示例5: pearErrorHandler
/**
* A callback function that sets the default PEAR Error behaviour.
*
* @static
* @param PEAR_Error $oError A {@link PEAR_Error} object
*/
function pearErrorHandler($oError)
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Log message
$message = $oError->getMessage();
$debugInfo = $oError->getDebugInfo();
OA::debug('PEAR' . " :: {$message} : {$debugInfo}", PEAR_LOG_ERR);
// If sesssion debug, send error info to screen
$msg = '';
if (empty($aConf['debug']['production'])) {
$GLOBALS['_MAX']['ERRORS'][] = $oError;
}
// Add backtrace info
if (!empty($aConf['debug']['showBacktrace'])) {
$msg .= 'PEAR backtrace: <div onClick="if (this.style.height) {this.style.height = null;this.style.width = null;} else {this.style.height = \'8px\'; this.style.width=\'8px\'}"';
$msg .= 'style="float:left; cursor: pointer; border: 1px dashed #FF0000; background-color: #EFEFEF; height: 8px; width: 8px; overflow: hidden; margin-bottom: 2px;">';
$msg .= '<pre wrap style="margin: 5px; background-color: #EFEFEF">';
ob_start();
print_r($oError->getBacktrace());
$msg .= ob_get_clean();
$msg .= '<hr></pre></div>';
$msg .= '<div style="clear:both"></div>';
}
if (defined('TEST_ENVIRONMENT_RUNNING')) {
// It's a test, stop execution
echo nl2br("Message: {$message}\ndebugInfo: {$debugInfo}\nbackTrace: {$msg}");
exit(1);
} elseif (defined('OA_WEBSERVICES_API_XMLRPC')) {
// It's an XML-RPC response
$oResponse = new XML_RPC_Response('', 99999, $message);
echo $oResponse->serialize();
exit;
} else {
// Send the error to the screen
echo MAX::errorObjToString($oError, $msg);
}
}
示例6: array
/**
* Push the error to the error stack.
*
* @param object $error PEAR_Error An error object
* @return void
* @access public
* @static
*/
function push_error(PEAR_Error $error)
{
self::errorstack()->push($error->getCode(), 'error', array('object' => $error), $error->getMessage(), false, $error->getBacktrace());
}