本文整理汇总了PHP中Exception::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::__toString方法的具体用法?PHP Exception::__toString怎么用?PHP Exception::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::__toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exceptionHandle
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;
}
示例2: __construct
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;
}
示例3: __toString
public function __toString()
{
if (class_exists('DebugException')) {
return DebugException::Display($this, __CLASS__);
}
return parent::__toString();
}
示例4: __toString
public function __toString()
{
if (WP_DEBUG !== true) {
return $this->friendly_msg;
}
return parent::__toString();
}
示例5: catchExceptions
/**
* 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);
}
示例6: __toString
public function __toString()
{
if ($message = $this->getMessageFromResponse()) {
return $message;
} else {
return parent::__toString();
}
}
示例7: __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));
}
示例8: __toString
/**
* 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;
}
示例9: __toString
public function __toString()
{
if (E_FW::get_Config('DEBUG')) {
return parent::__toString();
} else {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}
示例10: handle
/**
* 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;
}
示例11: __toString
public function __toString()
{
// очистим всю вышестоящую буферизацию без вывода её в браузер
!ob_get_level() ?: ob_end_clean();
parent::__toString();
echo joosRequest::is_ajax() ? $this->to_json() : $this->show();
die;
}
示例12: __toString
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;
}
示例13: __toString
public function __toString()
{
$msg = [];
foreach ($this->deserialized as $attr => $value) {
$msg[] = $attr . ': ' . $value;
}
$msg[] = 'parent message: ' . parent::__toString();
return implode("\n", $msg);
}
示例14: __toString
/**
* 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();
}
示例15: __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;
}