/** * 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; }
/** * 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 ''; }
/** * @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']; } }
/** * Ethna_Errorクラスのコンストラクタ * * @access public * @param int $level エラーレベル * @param string $message エラーメッセージ * @param int $code エラーコード * @param array $userinfo エラー追加情報(エラーコード以降の全ての引数) */ function Ethna_Error($message = null, $code = null, $mode = null, $options = null) { $controller =& Ethna_Controller::getInstance(); if ($controller !== null) { $this->i18n =& $controller->getI18N(); } // $options以降の引数->$userinfo if (func_num_args() > 4) { $userinfo = array_slice(func_get_args(), 4); if (count($userinfo) == 1) { if (is_array($userinfo[0])) { $userinfo = $userinfo[0]; } else { if (is_null($userinfo[0])) { $userinfo = array(); } } } } else { $userinfo = array(); } // メッセージ補正処理 if (is_null($message)) { // $codeからメッセージを取得する $message = $controller->getErrorMessage($code); if (is_null($message)) { $message = 'unkown error'; } } parent::PEAR_Error($message, $code, $mode, $options, $userinfo); // Ethnaフレームワークのエラーハンドラ(PEAR_Errorのコールバックとは異なる) Ethna::handleError($this); }
/** * 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
/** * 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(); }
/** * 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(); }
/** * Constructor. * * @param string $faultstring Message string for fault. * @param mixed $faultcode The faultcode. * @param mixed $faultactor * @param mixed $detail @see PEAR_Error * @param array $mode @see PEAR_Error * @param array $options @see PEAR_Error */ function SOAP_Fault($faultstring = 'unknown error', $faultcode = 'Client', $faultactor = null, $detail = null, $mode = null, $options = null) { parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail); if ($faultactor) { $this->error_message_prefix = $faultactor; } }
/** * Mail_Queue_Error constructor. * * @param mixed $code Mail_Queue error code, or string with error message. * @param integer $mode what 'error mode' to operate in * @param integer $level what error level to use for * $mode & PEAR_ERROR_TRIGGER * @param string $debuginfo additional debug info */ function Mail_Queue_Error($code = MAILQUEUE_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $file = __FILE__, $line = __LINE__, $debuginfo = '') { $debuginfo .= (empty($debuginfo) ? '' : ' - ') . 'FILE: ' . $file . ', LINE: ' . $line; if (is_int($code)) { parent::__construct('Mail Queue Error: ' . Mail_Queue::errorMessage($code), $code, $mode, $level, $debuginfo); } else { parent::__construct('Mail Queue Error: ' . $code, MAILQUEUE_ERROR, $mode, $level, $debuginfo); } }
public function authenticate() { $login = $_REQUEST['login']; $password = md5($_REQUEST['password']); if ($login == '' || $password == '') { $user = new PEAR_Error('authentication_error_blank'); } else { $user = new Administrator(); $user->whereAdd("login = '******'"); $user->whereAdd("password = '******'"); $user->find(); if ($user->N != 1) { $user = new PEAR_Error('authentication_error_invalid'); } else { $user->fetch(); } } return $user; }
/** * Attempt to authenticate the current user. * * @return object User object if successful, PEAR_Error otherwise. * @access public */ public function authenticate() { $username = $_POST['username']; $password = $_POST['password']; if ($username == '' || $password == '') { $user = new PEAR_Error('authentication_error_blank'); } else { $user = new User(); $user->username = (isset($configArray['Site']['institution']) ? $configArray['Site']['institution'] . ':' : '') . $username; $user->password = $password; if (!$user->find(true)) { $user = new PEAR_Error('authentication_error_invalid'); } else { $user->authMethod = 'Database'; $user->last_login = date('Y-m-d H:i:s'); $user->update(); } } return $user; }
/** * 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; }
/** * * * @param string * @param mixed * @param mixed * @param mixed * @param mixed */ function SOAP_Fault($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null) { if (is_array($userinfo)) { $actor = $userinfo['actor']; $detail = $userinfo['detail']; } else { $actor = 'Unknown'; $detail = $userinfo; } parent::PEAR_Error($message, $code, $mode, $options, $detail); $this->error_message_prefix = $actor; }
/** * 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"; }
/** * 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); }
/** * DB_DataObject_Error constructor. * * @param mixed $code DB error code, or string with error message. * @param integer $mode what "error mode" to operate in * @param integer $level what error level to use for $mode & PEAR_ERROR_TRIGGER * @param mixed $debuginfo additional debug info, such as the last query * * @access public * * @see PEAR_Error */ function __construct($message = '', $code = DB_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE) { parent::__construct('DB_DataObject Error: ' . $message, $code, $mode, $level); }
/** * Standard error constructor * * @param string The error message * @param int An optional integer error code */ function PayPal_Error($message, $errorcode = null) { parent::PEAR_error($message, $errorcode); }
/** * MDB2_Schema_Error constructor. * * @param mixed error code, or string with error message. * @param int what 'error mode' to operate in * @param int what error level to use for $mode & PEAR_ERROR_TRIGGER * @param mixed additional debug info, such as the last query * @access public */ function __construct($code = MDB2_SCHEMA_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null) { parent::__construct('MDB2_Schema Error: ' . MDB2_Schema::errorMessage($code), $code, $mode, $level, $debuginfo); }
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':
function Services_JSON_Error($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null) { parent::PEAR_Error($message, $code, $mode, $options, $userinfo); }
function KTNoLocalUser($aExtra = null) { parent::PEAR_Error(_kt('No local user with that username')); $this->aExtra = $aExtra; }
/** * DB_Error constructor * * @param mixed $code DB error code, or string with error message * @param int $mode what "error mode" to operate in * @param int $level what error level to use for $mode & * PEAR_ERROR_TRIGGER * @param mixed $debuginfo additional debug info, such as the last query * * @see PEAR_Error */ function __construct($code = DB_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null) { if (is_int($code)) { parent::__construct('DB Error: ' . DB::errorMessage($code), $code, $mode, $level, $debuginfo); } else { parent::__construct("DB Error: {$code}", DB_ERROR, $mode, $level, $debuginfo); } }
/** * Callback called when PEAR throws an error * * @param PEAR_Error $error */ function pear_handle_error($error) { echo '<strong>' . $error->GetMessage() . '</strong> ' . $error->getUserInfo(); echo '<br /> <strong>Backtrace </strong>:'; print_object($error->backtrace); }
/** * Starts a TLS connection. * * @return boolean True on success, PEAR_Error on failure. */ function _startTLS() { $res = $this->_doCmd('STARTTLS'); if (is_a($res, 'PEAR_Error')) { return $res; } if (!stream_socket_enable_crypto($this->_sock->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { return $this->_pear->raiseError('Failed to establish TLS connection', 2); } $this->_debug('STARTTLS negotiation successful'); // The server should be sending a CAPABILITY response after // negotiating TLS. Read it, and ignore if it doesn't. // Unfortunately old Cyrus versions are broken and don't send a // CAPABILITY response, thus we would wait here forever. Parse the // Cyrus version and work around this broken behavior. if (!preg_match('/^CYRUS TIMSIEVED V([0-9.]+)/', $this->_capability['implementation'], $matches) || version_compare($matches[1], '2.3.10', '>=')) { $this->_doCmd(); } // Query the server capabilities again now that we are under // encryption. $res = $this->_cmdCapability(); if (is_a($res, 'PEAR_Error')) { return $this->_pear->raiseError('Failed to connect, server said: ' . $res->getMessage(), 2); } return true; }
/** * Create a new DB object and connect to the specified database * * @param $dsn mixed "data source name", see the DB::parseDSN * method for a description of the dsn format. Can also be * specified as an array of the format returned by DB::parseDSN. * * @param $options mixed if boolean (or scalar), tells whether * this connection should be persistent (for backends that support * this). This parameter can also be an array of options, see * DB_common::setOption for more information on connection * options. * * @return object a newly created DB connection object, or a DB * error object on error * * @see DB::parseDSN * @see DB::isError */ function connect($dsn, $options = false) { if (is_array($dsn)) { $dsninfo = $dsn; } else { $dsninfo = DB::parseDSN($dsn); } switch ($dsninfo["phptype"]) { case 'pgsql': $type = 'postgres7'; break; case 'ifx': $type = 'informix9'; break; default: $type = $dsninfo["phptype"]; break; } if (is_array($options) && isset($options["debug"]) && $options["debug"] >= 2) { // expose php errors with sufficient debug level @(include_once "adodb-{$type}.inc.php"); } else { @(include_once "adodb-{$type}.inc.php"); } @($obj = NewADOConnection($type)); if (!is_object($obj)) { $obj = new PEAR_Error('Unknown Database Driver: ' . $dsninfo['phptype'], -1); return $obj; } if (is_array($options)) { foreach ($options as $k => $v) { switch (strtolower($k)) { case 'persist': case 'persistent': $persist = $v; break; #ibase #ibase case 'dialect': $obj->dialect = $v; break; case 'charset': $obj->charset = $v; break; case 'buffers': $obj->buffers = $v; break; #ado #ado case 'charpage': $obj->charPage = $v; break; #mysql #mysql case 'clientflags': $obj->clientFlags = $v; break; } } } else { $persist = false; } if (isset($dsninfo['socket'])) { $dsninfo['hostspec'] .= ':' . $dsninfo['socket']; } else { if (isset($dsninfo['port'])) { $dsninfo['hostspec'] .= ':' . $dsninfo['port']; } } if ($persist) { $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'], $dsninfo['password'], $dsninfo['database']); } else { $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'], $dsninfo['password'], $dsninfo['database']); } if (!$ok) { $obj = ADODB_PEAR_Error(); } return $obj; }
/** * 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); }
/** * 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(); }
/** * construct a new error instance * * You may either pass a message or an xml_parser resource as first * parameter. If a resource has been passed, the last error that * happened will be retrieved and returned. * * @param string|resource $msgorparser message or parser resource * @param integer $code error code * @param integer $mode error handling * @param integer $level error level * * @access public * @todo PEAR CS - can't meet 85char line limit without arg refactoring */ function __construct($msgorparser = 'unknown error', $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE) { if (is_resource($msgorparser)) { $code = xml_get_error_code($msgorparser); $msgorparser = sprintf('%s at XML input line %d:%d', xml_error_string($code), xml_get_current_line_number($msgorparser), xml_get_current_column_number($msgorparser)); } parent::__construct($msgorparser, $code, $mode, $level); }
function _tarError(PEAR_Error $error) { throw new Am_Exception_InputError('Upgrade unpacking problem: ' . $error->getMessage()); }
/** * 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); } }