public static function exceptionHandle(Exception $exception) { if (DEBUG_MODE) { //直接输出调试信息 echo nl2br($exception->__toString()); echo '<hr /><p>Router:</p><pre>'; print_r(Singleton::getInstance('Router')); echo '</pre>'; } else { $code = $exception->getCode(); $message = nl2br($exception->getMessage()); /* 如果错误码"可能为"合法的http状态码则尝试设置, setStatus()方法会忽略非法的http状态码. */ if ($code >= 400 && $code <= 505 && !headers_sent()) { ResponseModule::setStatus($code); } $var_list = array('message' => $message, 'code' => $code, 'file' => $exception->getFile(), 'url' => Singleton::getInstance('Router')->getUrl()); if ($error_file = self::_getErrorFilePath($code)) { Lugit::$view = new View($var_list); Lugit::$view->render($error_file); } else { echo 'No error page is found.<pre>'; print_r($var_list); echo '</pre>'; } } exit; }
public function __construct($correlationId, Exception $exception) { parent::__construct($correlationId, null, null); $this->rootCause = $exception->getTraceAsString(); $this->faultString = $exception->getMessage(); if ($exception instanceof ServiceException) { $this->extendedData = $exception->getCode(); } else { $this->extendedData = $exception->__toString(); } $this->faultDetail = $exception->__toString(); $this->SetError(); $this->m_authException = $exception instanceof WebORBAuthenticationException; }
public function __toString() { if (class_exists('DebugException')) { return DebugException::Display($this, __CLASS__); } return parent::__toString(); }
public function __toString() { if (WP_DEBUG !== true) { return $this->friendly_msg; } return parent::__toString(); }
/** * Catch Exceptions * @param Exception $err */ function catchExceptions($err) { global $config; echo "Error with your request! Please try again later. " . "If the problem persists contact <a href=\"" . $config['contact'] . "\">" . $config['contact'] . "</a>."; error_log($err->__toString(), 0); exit(1); }
public function __toString() { if ($message = $this->getMessageFromResponse()) { return $message; } else { return parent::__toString(); } }
/** * convert the exception into a string representation. * if the debug is null, just return normal output. * if the output is printable, attach the debug as a string and return it. * if debug is an object and has a __toString method, go with that. * otherwise, the debug must be an array or some other complex structure. * use print_r to represent the debug. */ public function __toString() { $out = parent::__toString(); if ($this->debug === NULL) { return $out; } return $out . self::DEBUG_HEADER . self::formatDebugOutput(self::stringify($this->debug)); }
/** * Override __toString() to show the response data, if available. * * @return string */ public function __toString() { $string = parent::__toString(); if ($responseData = $this->getResponseData()) { $string .= "\nresponse body data: " . print_r($responseData, true); } return $string; }
public function __toString() { if (E_FW::get_Config('DEBUG')) { return parent::__toString(); } else { return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; } }
/** * Tries to handle the exception. * * @param Exception $e * @return true */ function handle(Exception $e) { if (!$e instanceof ErrorException || $e->getSeverity() & $this->level) { fwrite(STDERR, $e->__toString()); $this->doExit($e->getCode()); } return false; }
public function __toString() { // очистим всю вышестоящую буферизацию без вывода её в браузер !ob_get_level() ?: ob_end_clean(); parent::__toString(); echo joosRequest::is_ajax() ? $this->to_json() : $this->show(); die; }
public function __toString() { if (empty($this->srcFile)) { return parent::__toString(); } $res = sprintf('From %s around line %d' . "\n", $this->srcFile, $this->srcLine); $res .= parent::__toString(); return $res; }
public function __toString() { $msg = []; foreach ($this->deserialized as $attr => $value) { $msg[] = $attr . ': ' . $value; } $msg[] = 'parent message: ' . parent::__toString(); return implode("\n", $msg); }
/** * String representation of the exception * * @return string */ public function __toString() { if (version_compare(PHP_VERSION, '5.3.0', '<')) { if (null !== ($e = $this->getPrevious())) { return $e->__toString() . "\n\nNext " . parent::__toString(); } } return parent::__toString(); }
/** * Append querylog to regular exception __toString * * @return string String representation of the exception */ public function __toString() { // Get regular message $toString = parent::__toString() . \PHP_EOL; // Append query log $toString .= \implode(\PHP_EOL, $this->queryLog); // Return String representation return $toString; }
/** * String representation of the exception * * @return string */ public function __toString() { if (version_compare(PHP_VERSION, '5.3.0', '<')) { $previous = $this->getPrevious(); if (null !== $previous) { return $previous->__toString() . '\\n\\nNext:\\n' . parent::__toString(); } } return parent::__toString(); }
/** * Set exception as response. Exception will be processed as error. * @param Exception $exception the php exception. * @TODO filter some exception message. */ public function setException($exception) { $this->state = self::STATE_ERROR; $this->errorCode = -1; if ($exception instanceof PException) { $this->errorMessage = $exception->getMessage(); } else { $this->errorMessage = YII_DEBUG ? $exception->__toString() : "System Exception"; } }
/** * A new error result * * @param string $message Message * @param int $code Error Code * @param Exception $exception Exception object * * @return void */ public function __construct($message, $code = "", Exception $exception = NULL) { if ($code == "") { $code = ErrorResult::$RESULT_FAIL; } if ($exception != NULL) { $this->setResult($exception->__toString()); } $this->setStatusCode($code, $message); }
public function __toString() { $env = XF_Config::getInstance()->getEnvironmental(); if ($env == 'development') { if ($this->code == 404) { header('HTTP/1.1 404 Not Found'); } else { header('HTTP/1.1 500 Internal Server Error'); } echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>'; echo '<title>Application Error</title>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; echo '</head><body>'; echo '<pre>'; echo parent::__toString(); echo "\n\n\nRequest URL: " . XF_Controller_Request_Http::getInstance()->getRequestUrl() . "\n"; echo "Params:\n"; print_r(XF_Controller_Request_Http::getInstance()->getParams()); echo "\nRewrites: \n"; $debug = XF_DataPool::getInstance()->get('DEBUG'); print_r($debug['Rewites']); $_querys = XF_DataPool::getInstance()->get('Querys', array()); echo '<br/>Querys(' . count($_querys) . ') Time:' . XF_DataPool::getInstance()->get('QueryTimeCount', 0) . 's<br/>'; print_r($_querys); echo '<br/>ReadCache(' . XF_DataPool::getInstance()->get('CacheTimeCount', 0) . 's)<br/>'; print_r(XF_DataPool::getInstance()->get('CacheTimeList', array())); echo '<br/>RunApplication:' . XF_DataPool::getInstance()->get('RunApplication') . 's'; echo '<br/>RunBootstrap:' . XF_DataPool::getInstance()->get('RunBootstrap') . 's'; echo '<br/>LoadFile:' . sprintf("%.5fs", XF_Application::getInstance()->loadFileTime()); echo '<br/>RunTime:' . sprintf('%.5f', microtime(true) - APP_START_TIME) . 's'; echo '</pre>'; echo '</body></html>'; } else { $string = $title = ''; if ($this->code == 404) { header('HTTP/1.1 404 Not Found'); $title = 'Not Found'; $string = '<h1 style="font-size:60px;">:( 404</h1>'; $string .= '<p>您请求的网页不存在或已删除!<br/><br/><a href="/">返回</a></p>'; } else { header('HTTP/1.1 500 Internal Server Error'); $title = 'Internal Server Error'; $string = '<h1 style="font-size:60px;">:( 500</h1>'; $string .= '<p>您请求的网页存在错误,请稍后再访问!<br/><br/><a href="/">返回</a></p>'; } echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>'; echo '<title>' . $title . '</title>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; echo '</head><body style="padding:10px;">'; echo $string; echo '<p style="color:#999;font-size:14px;">URL:' . XF_Controller_Request_Http::getInstance()->getRequestUrl() . '</p>'; echo '</body></html>'; } return ''; }
public function __toString() { if ($this->query == "") { return parent::__toString(); } $msg = $this->message; $this->message .= "\nCurrent query was {$this->query}"; $str = parent::__toString(); $this->message = $msg; return $str; }
function __toString() { if (phpversion() >= 5) { return parent::__toString(); } $msg = "Message: " . $this->message . "\n"; $msg = "Error body: " . $this->error . "\n"; $msg .= "Time: " . $this->time . "\n"; $msg .= "Stream: " . $this->stream; return $msg; }
public static function logException($channel, $message, Exception $exception) { if (!self::isChannelAllowed($channel)) { return; } $line = date("c"); $line .= " [" . LoggingConstants::getLogChannelName($channel) . "] "; $line .= self::getSource(); $line .= $message . "\r\n"; $line .= $exception->__toString() . "\r\n"; self::$s_logger->log($line); }
function __toString() { if (phpversion() >= 5) { return parent::__toString(); } $msg = "Message: " . $this->message . "\n"; $msg = "Code: " . $this->code . "\n"; $msg .= "Time: " . $this->time . "\n"; $msg .= "Headers: " . print_r($this->headers, true) . "\n"; $msg .= "Body: " . $this->body . "\n"; return $msg; }
public function __toString() { $str = parent::__toString(); if (!empty($this->_errorMessages)) { $str .= "\nError messages:\n"; foreach ($this->_errorMessages as $err) { if (is_object($err) || is_array($err)) { $err = json_encode($err); } $str .= "\t- " . $err . "\n"; } } return $str; }
public function __toString() { if ($this->getLogging() == true) { $this->saveLog(); } if (Framework::getTpl()) { Framework::getTpl()->assign('exception', $this); Framework::getTpl()->assign('returnLink', isset($_SERVER['HTTP_REFERER']) == true && empty($_SERVER['HTTP_REFERER']) == false ? $_SERVER['HTTP_REFERER'] : ''); $output = Framework::getTpl()->fetch('exception/' . $this->tenplateName . '.tpl'); echo $output; } else { echo parent::__toString(); } exit; }
/** * Return a suitable string representation of the database error. * * @return string */ public function __toString() { $result = parent::__toString(); if ($this->errstr !== null) { $result .= "\nerror string: " . $this->errstr; } if ($this->sql_error_code !== null) { $result .= ' [' . $this->sql_error_code . ']'; } if ($this->state !== null) { $result .= "\nSQL state: " . $this->state; } if ($this->sql !== null) { $result .= "\nSQL code: " . $this->sql; } return $result; }
public function __toString() { return __("Prázdná hodnota pro: ", KT_DOMAIN) . $this->getReferenceName() . "\n" . parent::__toString(); }
/** * Prints the message of the Exception if it's not null. * @param Exception $t */ public static function printMessage(Exception $t) { if (self::$err === null) { // Make sure our error output is initialized self::initializeOutputStreams(); } if (self::getMsgOutputLevel() >= Project::MSG_VERBOSE) { self::$err->write($t->__toString() . PHP_EOL); } else { self::$err->write($t->getMessage() . PHP_EOL); } }
/** * Report an exception to the user */ protected static function report(Exception $e) { global $wgShowExceptionDetails; $cmdLine = MWException::isCommandLine(); if ($e instanceof MWException) { try { // Try and show the exception prettily, with the normal skin infrastructure $e->report(); } catch (Exception $e2) { // Exception occurred from within exception handler // Show a simpler error message for the original exception, // don't try to invoke report() $message = "MediaWiki internal error.\n\n"; if ($wgShowExceptionDetails) { $message .= 'Original exception: ' . $e->__toString() . "\n\n" . 'Exception caught inside exception handler: ' . $e2->__toString(); } else { $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information."; } $message .= "\n"; if ($cmdLine) { self::printError($message); } else { self::escapeEchoAndDie($message); } } } else { $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class($e) . "\"\n" . $e->__toString() . "\n"; if ($wgShowExceptionDetails) { $message .= "\n" . $e->getTraceAsString() . "\n"; } if ($cmdLine) { self::printError($message); } else { self::escapeEchoAndDie($message); } } }
/** * Returns a string representation of the exception. * * @return string The exception as a string. */ public function __toString() { return parent::__toString() . "\nValue:{$this->_value}"; }