Beispiel #1
0
    /**
     * Returns the value of the given property; throws
     * InvalidPropertyHandlerException if the property didn't exist.
     *
     * @param string $p_property
     * @return mixed
     */
    public function __get($p_property)
    {
        $p_property = MetaAction::TranslateProperty($p_property);

        if ($p_property == 'defined') {
            return $this->defined();
        }
        if ($p_property == 'is_error') {
            return PEAR::isError($this->m_error);
        }
        if ($p_property == 'error_code') {
            return PEAR::isError($this->m_error) ? $this->m_error->getCode() : null;
        }
        if ($p_property == 'error_message') {
            return PEAR::isError($this->m_error) ? $this->m_error->getMessage() : null;
        }
        if ($p_property == 'ok') {
            return $this->getError() === ACTION_OK;
        }
        if ($p_property == 'name') {
            return $this->m_name;
        }

        if (!is_array($this->m_properties)
        || !array_key_exists($p_property, $this->m_properties)) {
            $this->trigger_invalid_property_error($p_property);
        }
        if (is_string($this->m_properties[$p_property])
        && method_exists($this, $this->m_properties[$p_property])) {
            $methodName = $this->m_properties[$p_property];
            return $this->$methodName();
        }
        return $this->m_properties[$p_property];
    } // fn __get
Beispiel #2
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;
    }
Beispiel #3
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);
 }
Beispiel #4
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);
     }
 }
Beispiel #5
0
 /**
  * A method to display an M2M/Dashboard error
  *
  * @param PEAR_Error $oError
  */
 function showError($oError)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     $oTpl = new OA_Admin_Template('dashboard/error.html');
     $errorCode = $oError->getCode();
     $nativeErrorMessage = $oError->getMessage();
     // Set error message
     if (isset($GLOBALS['strDashboardErrorMsg' . $errorCode])) {
         $errorMessage = $GLOBALS['strDashboardErrorMsg' . $errorCode];
     } else {
         if (!empty($nativeErrorMessage)) {
             $errorMessage = $nativeErrorMessage;
             // Don't show this message twice on error page
             unset($nativeErrorMessage);
         } else {
             $errorMessage = $GLOBALS['strDashboardGenericError'];
         }
     }
     // Set error description
     if (isset($GLOBALS['strDashboardErrorDsc' . $errorCode])) {
         $errorDescription = $GLOBALS['strDashboardErrorDsc' . $errorCode];
     }
     $oTpl->assign('errorCode', $errorCode);
     $oTpl->assign('errorMessage', $errorMessage);
     $oTpl->assign('systemMessage', $nativeErrorMessage);
     $oTpl->assign('errorDescription', $errorDescription);
     $oTpl->display();
 }
Beispiel #6
0
 /**
  * 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());
 }
Beispiel #7
0
 /**
  * Exception constructor.
  *
  * @param PEAR_Error $error The PEAR error.
  */
 public function __construct(PEAR_Error $error)
 {
     parent::__construct($error->getMessage(), $error->getCode());
     $this->details = $this->_getPearTrace($error);
 }
Beispiel #8
0
function PEAR_ErrorToPEAR_Exception(PEAR_Error $err)
{
    //DB_DataObject throws error when an empty set would be returned
    //That behavior is weird, and not how the rest of StatusNet works.
    //So just ignore those errors.
    if ($err->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
        return;
    }
    $msg = $err->getMessage();
    $userInfo = $err->getUserInfo();
    // Log this; push the message up as an exception
    common_log(LOG_ERR, "PEAR Error: {$msg} ({$userInfo})");
    // HACK: queue handlers get kicked by the long-query killer, and
    // keep the same broken connection. We die here to get a new
    // process started.
    if (php_sapi_name() == 'cli' && preg_match('/nativecode=2006/', $userInfo)) {
        common_log(LOG_ERR, "Lost DB connection; dying.");
        exit(100);
    }
    if ($err->getCode()) {
        throw new PEAR_Exception($err->getMessage(), $err->getCode());
    }
    throw new PEAR_Exception($err->getMessage());
}