Пример #1
0
    /**
     * 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());
        $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
0
 /**
  * Adds a PEAR error to the stack for the package.
  *
  * @param PEAR_Error $error
  * @param integer    $code
  * @param string     $message
  * @param string     $level
  * @param array      $params
  * @param array      $backtrace
  */
 function pushPEARError($error, $code, $message = false, $level = 'exception', $params = array(), $backtrace = false)
 {
     $time = explode(' ', microtime());
     $time = $time[1] + $time[0];
     if (!$backtrace) {
         $backtrace = debug_backtrace();
     }
     Piece_Unity_Error::push($code, $message, 'exception', $params, array('code' => $error->getCode(), 'message' => $error->getMessage(), 'params' => array('userinfo' => $error->getUserInfo(), 'debuginfo' => $error->getDebugInfo()), 'package' => 'PEAR', 'level' => 'exception', 'time' => $time), $backtrace);
 }
Пример #3
0
 /**
  * PEAR error handler
  *
  * @param object $error PEAR Error object
  *
  * @return void
  * @ignore
  */
 public static function onPearError(PEAR_Error $error)
 {
     $trace = debug_backtrace();
     array_shift($trace);
     array_shift($trace);
     array_shift($trace);
     $options['file'] = $trace[0]['file'];
     $options['line'] = $trace[0]['line'];
     $options['trace'] = $trace;
     $options['package'] = self::PACKAGE_PEAR;
     $debugInfo = $error->getDebugInfo();
     $userInfo = $error->getUserInfo();
     $trace = $error->getBackTrace();
     $info = array('Error Type' => $error->getType(), 'Debug Info' => $error->getUserInfo());
     if ($debugInfo !== $userInfo) {
         $info['User Info'] = $userInfo;
     }
     if (self::$_config[self::CONFIG_DEBUG] === true) {
         self::error('PEAR Error', $error->getCode() . ' ' . $error->getMessage(), $info, $options);
     } else {
         error_log('PEAR Error' . $error->getCode() . ' ' . $error->getMessage() . " in file[{$options['file']}] on line [{$options['line']}", 0);
     }
 }