/** * Exception constructor. * * @param PEAR_Error $error The PEAR error. */ public function __construct(PEAR_Error $error) { parent::__construct($error->getMessage() . $this->_getPearTrace($error), $error->getCode()); if ($details = $error->getUserInfo()) { $this->details = $details; } }
/** * Overloads getMessage() to return an equivalent FileMaker Web Publishing * Engine error if no message is explicitly set and this object has an * error code. * * @return string Error message. */ function getMessage() { if ($this->message === null && $this->getCode() !== null) { return $this->getErrorString(); } return parent::getMessage(); }
/** * 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; }
/** * 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
/** * @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']; } }
/** * 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); } }
/** * 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(); }
if (!$stamm) { $data["CID"] = $_SESSION["loginCRM"]; // Dann halt beim Absender in den Thread eintragen $data["cause"] = $Subject . "|" . $_POST["TO"]; insCall($data, $_FILES); } $TO = ""; $CC = ""; $msg = "Mail versendet"; $Subject = ""; $BodyText = ""; if ($_POST["QUELLE"]) { header("Location: " . $referer); } } else { $msg = "Fehler beim Versenden " . PEAR_Error::getMessage(); //$TO=$_POST["TO"]; $CC=$_POST["CC"]; $msg="Fehler beim Versenden ".PEAR_Error::getMessage (); //$Subject=$_POST["Subject"]; $BodyText=$_POST["BodyText"]; } } else { $Subject = preg_replace("/(content-type:|bcc:|cc:|to:|from:)/im", "", $_POST["Subject"]); $BodyText = preg_replace("/(content-type:|bcc:|cc:|to:|from:)/im", "", $_POST["BodyText"]); } } else { $user = getUserStamm($_SESSION["loginCRM"]); $BodyText = ""; // \n".$MailSign; } } switch ($USER['mandsig']) { case '0':
/** * Callback function to handle PEAR errors in a command-line-friendly way. * * @param PEAR_Error $error The error object. * * @return void */ function utilErrorHandler($error) { echo $error->getMessage() . "\n"; exit(1); }
/** * エラー処理用をおこなう * * PEAR_Error のインスタンス作成時に呼ばれるコールバック関数 * * @static * @param PEAR_Error $error */ function errorHandler($error) { if (OPENPNE_DB_ERROR_LOG) { require_once 'Log.php'; $msg = sprintf("msg:-> %s\t info:-> %s", $error->getMessage(), $error->getUserInfo()); $log = OPENPNE_VAR_DIR . '/log/db_errors.log'; $file =& Log::singleton('file', $log, 'db', null, PEAR_LOG_ERR); $file->log($msg, PEAR_LOG_ERR); } }
/** * Build a standardized string describing the current SMTP error. * * @param string $text Custom string describing the error context. * @param PEAR_Error $error PEAR_Error object. * @param integer $e_code Error code. * * @throws Horde_Mail_Exception */ protected function _error($text, $error, $e_code) { /* Split the SMTP response into a code and a response string. */ list($code, $response) = $this->_smtp->getResponse(); /* Abort current SMTP transaction. */ $this->_smtp->rset(); /* Build our standardized error string. */ throw new Horde_Mail_Exception($text . ' [SMTP: ' . $error->getMessage() . " (code: {$code}, response: {$response})]", $e_code); }
/** * 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()); }
/** * Callback function to handle any PEAR errors that are thrown. * * @param PEAR_Error $error The error object. * * @return void */ function handlePEARError($error) { global $configArray; // It would be really bad if an error got raised from within the error handler; // we would go into an infinite loop and run out of memory. To avoid this, // we'll set a static value to indicate that we're inside the error handler. // If the error handler gets called again from within itself, it will just // return without doing anything to avoid problems. We know that the top-level // call will terminate execution anyway. static $errorAlreadyOccurred = false; if ($errorAlreadyOccurred) { return; } else { $errorAlreadyOccurred = true; } // Set appropriate HTTP header based on error (404 for missing record, 500 for // other problems): $msg = $error->getMessage(); if ($msg == 'Record Does Not Exist' || stristr($msg, 'cannot access record')) { header('HTTP/1.1 404 Not Found'); } else { header('HTTP/1.1 500 Internal Server Error'); } // Display an error screen to the user: $interface = new UInterface(); $interface->assign('error', $error); $interface->assign('debug', $configArray['System']['debug']); $interface->display('error.tpl'); // Exceptions we don't want to log $doLog = true; // Microsoft Web Discussions Toolbar polls the server for these two files // it's not script kiddie hacking, just annoying in logs, ignore them. if (strpos($_SERVER['REQUEST_URI'], "cltreq.asp") !== false) { $doLog = false; } if (strpos($_SERVER['REQUEST_URI'], "owssvr.dll") !== false) { $doLog = false; } // If we found any exceptions, finish here if (!$doLog) { exit; } // Log the error for administrative purposes -- we need to build a variety // of pieces so we can supply information at five different verbosity levels: $baseError = $error->toString(); $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'none'; $basicServer = " (Server: IP = {$_SERVER['REMOTE_ADDR']}, " . "Referer = {$referer}, " . "User Agent = {$_SERVER['HTTP_USER_AGENT']}, " . "Request URI = {$_SERVER['REQUEST_URI']})"; $detailedServer = "\nServer Context:\n" . print_r($_SERVER, true); $basicBacktrace = "\nBacktrace:\n"; if (is_array($error->backtrace)) { foreach ($error->backtrace as $line) { $basicBacktrace .= "{$line['file']} line {$line['line']} - " . "class = {$line['class']}, function = {$line['function']}\n"; } } $detailedBacktrace = "\nBacktrace:\n" . print_r($error->backtrace, true); $errorDetails = array(1 => $baseError, 2 => $baseError . $basicServer, 3 => $baseError . $basicServer . $basicBacktrace, 4 => $baseError . $detailedServer . $basicBacktrace, 5 => $baseError . $detailedServer . $detailedBacktrace); $logger = new Logger(); $logger->log($errorDetails, PEAR_LOG_ERR); exit; }
/** * 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); }
/** * A static method to restart with a login screen, displaying an error message * * @static * * @param PEAR_Error $oError */ function displayError($oError) { OA_Auth::restart($oError->getMessage()); }
/** * Returns the detailled error message of an PEAR_Error or an Exception * * @param PEAR_Error|Exception $error Error object * * @return string Detailled error message */ function get_detail_error_msg($error) { if ($error instanceof Exception) { $msg = $error->__toString(); } else { if ($error instanceof PEAR_Error) { $msg = $error->getMessage() . '... ' . $error->getUserInfo(); } else { $msg = (string) $error; } } return $msg; }
/** * Determines whether an error is a catalog connection error that should be * displayed to the user or raised as a general error. Formats a displayable * error appropriately. * * @param PEAR_Error $error PEAR error * * @return void */ protected function handleCatalogError($error) { global $configArray, $interface, $user; $msg = $error->getMessage(); if ($msg == 'authentication_error_technical') { $interface->assign('errorMsg', 'catalog_connection_failure_explanation'); } else { if ($msg == 'catalog_login_failed') { if ($user) { $msg = translate($msg) . ' ' . translate('catalog_login_check_account'); $accountId = null; // A failed login clears cat_username from $user, so fetch it from // interface $currentAccount = $interface->get_template_vars('currentCatalogAccount'); $catAccounts = $user->getCatalogAccounts(); foreach ($catAccounts as $catAccount) { if ($catAccount['cat_username'] == $currentAccount) { $accountId = $catAccount['id']; break; } } $accountUrl = $configArray['Site']['url'] . "/MyResearch/Accounts"; if (!is_null($accountId)) { $accountUrl .= "?edit={$accountId}"; } } $interface->assign('errorMsg', str_replace('%%url%%', $accountUrl, $msg)); } else { PEAR::raiseError($error); } } }
/** * 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); }
/** * Retrieve the error message for this object * * Error messages are dynamically generated from the callback * set by {@link Error_Raise::initialize()}, or passed to * {@link Error_Raise::setErrorMsgGenerator()}. The function is passed the * error code, user information that was set in the constructor, and the * display state, and must return a string. * * An example error message generator is Error_Raises's own generator * found at {@link Error_Raise::_getErrorMessage()} * @uses getErrorPrefix() grab the error prefix generated dynamically * from context information * @return string * @throws ERROR_RAISE_ERROR_CODENOMSG if no error message generator * function has been registered for this package * @param ERROR_RAISE_TEXT|ERROR_RAISE_HTML|ERROR_RAISE_ANSI format state * that error message should be in * @param boolean determines whether source code context is displayed with * the message. By default, the presence of a context grabbing * function sets this to true. Pass in true to turn off context * display */ function getMessage($state = ERROR_RAISE_TEXT, $context = false) { $package = $this->_package; if (isset($GLOBALS['_ERROR_RAISE_MSGS'][$package])) { if (function_exists('debug_backtrace')) { $e = $this->_grabBacktrace($this->backtrace, $this, $this->_type); if (PEAR::isError($e)) { return $e; } } $this->error_message_prefix = $this->getErrorPrefix($state, $context); $this->message = $this->getBareMessage($state); $this->error_message_suffix = $this->getErrorSuffix($state, $context); return $this->error_message_prefix . $this->message . $this->error_message_suffix; } else { $e = Error_Raise::warning('error_Raise', ERROR_RAISE_ERROR_CODENOMSG, array('package' => $package)); if (strlen($this->message)) { return parent::getMessage(); } return $e->getMessage($state); } }
/** * helper callback for extracting Archive_Tar errors * * @param PEAR_Error|null $err * @return array * @access private */ function _extractErrors($err = null) { static $errors = array(); if ($err === null) { $e = $errors; $errors = array(); return $e; } $errors[] = $err->getMessage(); }
/** * Deliver an error page * * @param PEAR_Error $error The error. * @param array $headers The HTTP headers to deliver with the response * @param string $title The page title * @param string $headline The headline of the page * @param string $body The message to display on the page */ function _errorPage($error, $headers, $title, $headline, $body) { global $conf; /* Print the headers */ foreach ($headers as $line) { header($line); } /* Print the page */ echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"; echo "<html><head><title>" . $title . "</title></head>\n"; echo "<body>\n"; echo "<h1>" . $headline . "</h1>\n"; echo "<p>" . $body . "</p>\n"; if (!empty($error)) { echo "<hr><pre>" . $error->getMessage() . "</pre>\n"; Horde::log($error, 'ERR'); } echo "<hr>\n"; echo isset($_SERVER['SERVER_SIGNATURE']) ? $_SERVER['SERVER_SIGNATURE'] : '' . "\n"; echo "</body></html>\n"; }
/** * Dump an error * * @param PEAR_Error $err The error object * * @return void */ function dumpError($err) { echo $err->getMessage(); exit; }
function _tarError(PEAR_Error $error) { throw new Am_Exception_InputError('Upgrade unpacking problem: ' . $error->getMessage()); }
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()); }