Esempio n. 1
0
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 $message;
        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);
    }
}