Browse Source

finished error handler.

tags/2.0.0-beta
Qiang Xue 13 years ago
parent
commit
7c06cc03d7
  1. 473
      framework/base/ErrorHandler.php
  2. 26
      framework/base/View.php
  3. 71
      framework/views/error.php
  4. 212
      framework/views/exception.php

473
framework/base/ErrorHandler.php

@ -47,6 +47,7 @@ namespace yii\base;
* {@link CApplication::getErrorHandler()}. * {@link CApplication::getErrorHandler()}.
* *
* @property array $error The error details. Null if there is no error. * @property array $error The error details. Null if there is no error.
* @property string $versionInfo
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
@ -62,11 +63,6 @@ class ErrorHandler extends ApplicationComponent
* @var integer maximum number of trace source code lines to be displayed. Defaults to 10. * @var integer maximum number of trace source code lines to be displayed. Defaults to 10.
*/ */
public $maxTraceSourceLines = 10; public $maxTraceSourceLines = 10;
/**
* @var string the application administrator information (could be a name or email link). It is displayed in error pages to end users. Defaults to 'the webmaster'.
*/
public $adminInfo = 'the webmaster';
/** /**
* @var boolean whether to discard any existing page output before error display. Defaults to true. * @var boolean whether to discard any existing page output before error display. Defaults to true.
*/ */
@ -78,9 +74,12 @@ class ErrorHandler extends ApplicationComponent
*/ */
public $errorAction; public $errorAction;
private $_error; public $exceptionView = '@yii/views/exception.php';
public $errorView = '@yii/views/error.php';
/**
* @var \Exception the exception that is being handled currently
*/
public $exception; public $exception;
public $compactOutput;
public function init() public function init()
{ {
@ -88,36 +87,26 @@ class ErrorHandler extends ApplicationComponent
set_error_handler(array($this, 'handleError'), error_reporting()); set_error_handler(array($this, 'handleError'), error_reporting());
} }
protected function logException($exception) /**
{ * Handles PHP execution errors such as warnings, notices.
$category = get_class($exception); *
if ($exception instanceof HttpException) { * This method is implemented as a PHP error handler. It requires
$category .= '\\' . $exception->statusCode; * that constant YII_ENABLE_ERROR_HANDLER be defined true.
} elseif ($exception instanceof \ErrorException) { *
$category .= '\\' . $exception->getSeverity(); * This method will first raise an `error` event.
} * If the error is not handled by any event handler, it will call
\Yii::error((string)$exception, $category); * {@link getErrorHandler errorHandler} to process the error.
} *
* The application will be terminated by this method.
protected function clearOutput() *
{ * @param integer $code the level of the error raised
// the following manual level counting is to deal with zlib.output_compression set to On * @param string $message the error message
for ($level = ob_get_level(); $level > 0; --$level) { * @param string $file the filename that the error was raised in
@ob_end_clean(); * @param integer $line the line number the error was raised at
} */
} public function handleError($code, $message, $file, $line)
protected function simple()
{
if (YII_DEBUG) {
echo '<h1>' . get_class($exception) . "</h1>\n";
echo '<p>' . $exception->getMessage() . ' (' . $exception->getFile() . ':' . $exception->getLine() . ')</p>';
echo '<pre>' . $exception->getTraceAsString() . '</pre>';
} else
{ {
echo '<h1>' . get_class($exception) . "</h1>\n"; throw new \ErrorException($message, 0, $code, $file, $line);
echo '<p>' . $exception->getMessage() . '</p>';
}
} }
/** /**
@ -125,264 +114,51 @@ class ErrorHandler extends ApplicationComponent
*/ */
public function handleException($exception) public function handleException($exception)
{ {
$this->exception = $exception; // disable error capturing to avoid recursive errors while handling exceptions
// disable error capturing to avoid recursive errors
restore_error_handler(); restore_error_handler();
restore_exception_handler(); restore_exception_handler();
$this->exception = $exception;
$this->logException($exception); $this->logException($exception);
if ($this->discardExistingOutput) { if ($this->discardExistingOutput) {
$this->clearOutput(); $this->clearOutput();
} }
if ($this->compactOutput === null) { $this->render($exception);
// not in Web application, or not in AJAX request
$this->compactOutput = !(\Yii::$application instanceof \yii\web\Application) || isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';
}
if ($this->compactOutput) {
$this->simple();
return;
} }
if (($trace = $this->getExactTrace($exception)) === null) { protected function render($exception)
$fileName = $exception->getFile(); {
$errorLine = $exception->getLine(); if (\Yii::$application instanceof \yii\web\Application) {
if ($this->errorAction !== null) {
\Yii::$application->runController($this->errorAction);
} else { } else {
$fileName = $trace['file'];
$errorLine = $trace['line'];
}
$trace = $exception->getTrace();
foreach ($trace as $i => $t) {
if (!isset($t['file'])) {
$trace[$i]['file'] = 'unknown';
}
if (!isset($t['line'])) {
$trace[$i]['line'] = 0;
}
if (!isset($t['function'])) {
$trace[$i]['function'] = 'unknown';
}
unset($trace[$i]['object']);
}
$this->_error = $data = array(
'code' => $exception instanceof HttpException ? $exception->statusCode : 500,
'type' => get_class($exception),
'errorCode' => $exception->getCode(),
'message' => $exception->getMessage(),
'file' => $fileName,
'line' => $errorLine,
'trace' => $exception->getTraceAsString(),
'traces' => $trace,
);
if (!headers_sent()) { if (!headers_sent()) {
header("HTTP/1.0 {$data['code']} " . get_class($exception)); $errorCode = $exception instanceof HttpException ? $exception->statusCode : 500;
header("HTTP/1.0 $errorCode " . get_class($exception));
} }
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
if ($exception instanceof HttpException || !YII_DEBUG) { $this->renderAsText($exception);
$this->render('error', $data);
} else { } else {
$this->render('exception', $data); $this->renderAsHtml($exception);
}
}
/**
* Returns the details about the error that is currently being handled.
* The error is returned in terms of an array, with the following information:
* <ul>
* <li>code - the HTTP status code (e.g. 403, 500)</li>
* <li>type - the error type (e.g. 'CHttpException', 'PHP Error')</li>
* <li>message - the error message</li>
* <li>file - the name of the PHP script file where the error occurs</li>
* <li>line - the line number of the code where the error occurs</li>
* <li>trace - the call stack of the error</li>
* <li>source - the context source code where the error occurs</li>
* </ul>
* @return array the error details. Null if there is no error.
*/
public function getError()
{
return $this->_error;
}
/**
* Handles the PHP error.
* @param CErrorEvent $event the PHP error event
*/
protected function handleError($event)
{
$trace = debug_backtrace();
// skip the first 3 stacks as they do not tell the error position
if (count($trace) > 3)
$trace = array_slice($trace, 3);
$traceString = '';
foreach ($trace as $i => $t)
{
if (!isset($t['file']))
$trace[$i]['file'] = 'unknown';
if (!isset($t['line']))
$trace[$i]['line'] = 0;
if (!isset($t['function']))
$trace[$i]['function'] = 'unknown';
$traceString .= "#$i {$trace[$i]['file']}({$trace[$i]['line']}): ";
if (isset($t['object']) && is_object($t['object']))
$traceString .= get_class($t['object']) . '->';
$traceString .= "{$trace[$i]['function']}()\n";
unset($trace[$i]['object']);
} }
$app = Yii::app();
if ($app instanceof CWebApplication) {
switch ($event->code)
{
case E_WARNING:
$type = 'PHP warning';
break;
case E_NOTICE:
$type = 'PHP notice';
break;
case E_USER_ERROR:
$type = 'User error';
break;
case E_USER_WARNING:
$type = 'User warning';
break;
case E_USER_NOTICE:
$type = 'User notice';
break;
case E_RECOVERABLE_ERROR:
$type = 'Recoverable error';
break;
default:
$type = 'PHP error';
}
$this->_error = $data = array(
'code' => 500,
'type' => $type,
'message' => $event->message,
'file' => $event->file,
'line' => $event->line,
'trace' => $traceString,
'traces' => $trace,
);
if (!headers_sent())
header("HTTP/1.0 500 PHP Error");
if ($this->isAjaxRequest())
$app->displayError($event->code, $event->message, $event->file, $event->line);
else if (YII_DEBUG)
$this->render('exception', $data);
else
$this->render('error', $data);
}
else
$app->displayError($event->code, $event->message, $event->file, $event->line);
} }
} else {
/** $this->renderAsText($exception);
* Returns the exact trace where the problem occurs.
* @param \Exception $exception the uncaught exception
* @return array the exact trace where the problem occurs
*/
protected function getExactTrace($exception)
{
$traces = $exception->getTrace();
foreach ($traces as $trace) {
// property access exception
if (isset($trace['function']) && ($trace['function'] === '__get' || $trace['function'] === '__set')) {
return $trace;
}
}
return null;
}
/**
* Renders the view.
* @param string $view the view name (file name without extension).
* See {@link getViewFile} for how a view file is located given its name.
* @param array $data data to be passed to the view
*/
protected function render($view, $data)
{
if ($view === 'error' && $this->errorAction !== null)
Yii::app()->runController($this->errorAction);
else
{
// additional information to be passed to view
$data['version'] = $this->getVersionInfo();
$data['time'] = time();
$data['admin'] = $this->adminInfo;
include($this->getViewFile($view, $data['code']));
}
}
/**
* Determines which view file should be used.
* @param string $view view name (either 'exception' or 'error')
* @param integer $code HTTP status code
* @return string view file path
*/
protected function getViewFile($view, $code)
{
$viewPaths = array(
Yii::app()->getTheme() === null ? null : Yii::app()->getTheme()->getSystemViewPath(),
Yii::app() instanceof CWebApplication ? Yii::app()->getSystemViewPath() : null,
YII_PATH . DIRECTORY_SEPARATOR . 'views',
);
foreach ($viewPaths as $i => $viewPath)
{
if ($viewPath !== null) {
$viewFile = $this->getViewFileInternal($viewPath, $view, $code, $i === 2 ? 'en_us' : null);
if (is_file($viewFile))
return $viewFile;
}
}
}
/**
* Looks for the view under the specified directory.
* @param string $viewPath the directory containing the views
* @param string $view view name (either 'exception' or 'error')
* @param integer $code HTTP status code
* @param string $srcLanguage the language that the view file is in
* @return string view file path
*/
protected function getViewFileInternal($viewPath, $view, $code, $srcLanguage = null)
{
$app = Yii::app();
if ($view === 'error') {
$viewFile = $app->findLocalizedFile($viewPath . DIRECTORY_SEPARATOR . "error{$code}.php", $srcLanguage);
if (!is_file($viewFile))
$viewFile = $app->findLocalizedFile($viewPath . DIRECTORY_SEPARATOR . 'error.php', $srcLanguage);
} }
else
$viewFile = $viewPath . DIRECTORY_SEPARATOR . "exception.php";
return $viewFile;
} }
/** /**
* Returns server version information. * Returns server and Yii version information.
* If the application is in production mode, empty string is returned. * @return string server version information.
* @return string server version information. Empty if in production mode.
*/ */
protected function getVersionInfo() public function getVersionInfo()
{ {
if (YII_DEBUG) {
$version = '<a href="http://www.yiiframework.com/">Yii Framework</a>/' . \Yii::getVersion(); $version = '<a href="http://www.yiiframework.com/">Yii Framework</a>/' . \Yii::getVersion();
if (isset($_SERVER['SERVER_SOFTWARE'])) { if (isset($_SERVER['SERVER_SOFTWARE'])) {
$version = $_SERVER['SERVER_SOFTWARE'] . ' ' . $version; $version = $_SERVER['SERVER_SOFTWARE'] . ' ' . $version;
} }
} else {
$version = '';
}
return $version; return $version;
} }
@ -392,50 +168,46 @@ class ErrorHandler extends ApplicationComponent
* @param array $args arguments array to be converted * @param array $args arguments array to be converted
* @return string string representation of the arguments array * @return string string representation of the arguments array
*/ */
protected function argumentsToString($args) public function argumentsToString($args)
{ {
$count = 0;
$isAssoc = $args !== array_values($args); $isAssoc = $args !== array_values($args);
$count = 0;
foreach ($args as $key => $value) foreach ($args as $key => $value) {
{
$count++; $count++;
if ($count >= 5) { if ($count >= 5) {
if ($count > 5) if ($count > 5) {
unset($args[$key]); unset($args[$key]);
else } else {
$args[$key] = '...'; $args[$key] = '...';
}
continue; continue;
} }
if (is_object($value)) if (is_object($value)) {
$args[$key] = get_class($value); $args[$key] = get_class($value);
else if (is_bool($value)) } elseif (is_bool($value)) {
$args[$key] = $value ? 'true' : 'false'; $args[$key] = $value ? 'true' : 'false';
else if (is_string($value)) { } elseif (is_string($value)) {
if (strlen($value) > 64) if (strlen($value) > 64) {
$args[$key] = '"' . substr($value, 0, 64) . '..."'; $args[$key] = '"' . substr($value, 0, 64) . '..."';
else } else {
$args[$key] = '"' . $value . '"'; $args[$key] = '"' . $value . '"';
} }
else if (is_array($value)) } elseif (is_array($value)) {
$args[$key] = 'array(' . $this->argumentsToString($value) . ')'; $args[$key] = 'array(' . $this->argumentsToString($value) . ')';
else if ($value === null) } elseif ($value === null) {
$args[$key] = 'null'; $args[$key] = 'null';
else if (is_resource($value)) } elseif (is_resource($value)) {
$args[$key] = 'resource'; $args[$key] = 'resource';
}
if (is_string($key)) { if (is_string($key)) {
$args[$key] = '"' . $key . '" => ' . $args[$key]; $args[$key] = '"' . $key . '" => ' . $args[$key];
} } elseif ($isAssoc) {
else if ($isAssoc) {
$args[$key] = $key . ' => ' . $args[$key]; $args[$key] = $key . ' => ' . $args[$key];
} }
} }
$out = implode(", ", $args); return implode(', ', $args);
return $out;
} }
/** /**
@ -443,11 +215,10 @@ class ErrorHandler extends ApplicationComponent
* @param array $trace the trace data * @param array $trace the trace data
* @return boolean whether the call stack is from application code. * @return boolean whether the call stack is from application code.
*/ */
protected function isCoreCode($trace) public function isCoreCode($trace)
{ {
if (isset($trace['file'])) { if (isset($trace['file'])) {
$systemPath = realpath(dirname(__FILE__) . '/..'); return $trace['file'] === 'unknown' || strpos(realpath($trace['file']), YII_PATH . DIRECTORY_SEPARATOR) === 0;
return $trace['file'] === 'unknown' || strpos(realpath($trace['file']), $systemPath . DIRECTORY_SEPARATOR) === 0;
} }
return false; return false;
} }
@ -457,13 +228,13 @@ class ErrorHandler extends ApplicationComponent
* @param string $file source file path * @param string $file source file path
* @param integer $errorLine the error line number * @param integer $errorLine the error line number
* @param integer $maxLines maximum number of lines to display * @param integer $maxLines maximum number of lines to display
* @return string the rendering result
*/ */
protected function renderSourceCode($file, $errorLine, $maxLines) public function renderSourceCode($file, $errorLine, $maxLines)
{ {
$errorLine--; // adjust line number to 0-based from 1-based $errorLine--; // adjust line number to 0-based from 1-based
if ($errorLine < 0 || ($lines = @file($file)) === false || ($lineCount = count($lines)) <= $errorLine) if ($errorLine < 0 || ($lines = @file($file)) === false || ($lineCount = count($lines)) <= $errorLine) {
return ''; return;
}
$halfLines = (int)($maxLines / 2); $halfLines = (int)($maxLines / 2);
$beginLine = $errorLine - $halfLines > 0 ? $errorLine - $halfLines : 0; $beginLine = $errorLine - $halfLines > 0 ? $errorLine - $halfLines : 0;
@ -471,37 +242,101 @@ class ErrorHandler extends ApplicationComponent
$lineNumberWidth = strlen($endLine + 1); $lineNumberWidth = strlen($endLine + 1);
$output = ''; $output = '';
for ($i = $beginLine; $i <= $endLine; ++$i) for ($i = $beginLine; $i <= $endLine; ++$i) {
{
$isErrorLine = $i === $errorLine; $isErrorLine = $i === $errorLine;
$code = sprintf("<span class=\"ln" . ($isErrorLine ? ' error-ln' : '') . "\">%0{$lineNumberWidth}d</span> %s", $i + 1, CHtml::encode(str_replace("\t", ' ', $lines[$i]))); $code = sprintf("<span class=\"ln" . ($isErrorLine ? ' error-ln' : '') . "\">%0{$lineNumberWidth}d</span> %s", $i + 1, $this->htmlEncode(str_replace("\t", ' ', $lines[$i])));
if (!$isErrorLine) if (!$isErrorLine) {
$output .= $code; $output .= $code;
else } else {
$output .= '<span class="error">' . $code . '</span>'; $output .= '<span class="error">' . $code . '</span>';
} }
return '<div class="code"><pre>' . $output . '</pre></div>'; }
echo '<div class="code"><pre>' . $output . '</pre></div>';
}
public function renderTrace($trace)
{
$count = 0;
echo "<table>\n";
foreach ($trace as $n => $t) {
if ($this->isCoreCode($t)) {
$cssClass = 'core collapsed';
} elseif (++$count > 3) {
$cssClass = 'app collapsed';
} else {
$cssClass = 'app expanded';
}
$hasCode = $t['file'] !== 'unknown' && is_file($t['file']);
echo "<tr class=\"trace $cssClass\"><td class=\"number\">#$n</td><td class=\"content\">";
echo '<div class="trace-file">';
if ($hasCode) {
echo '<div class="plus">+</div><div class="minus">-</div>';
}
echo '&nbsp;';
echo $this->htmlEncode($t['file']) . '(' . $t['line'] . '): ';
if (!empty($t['class'])) {
echo '<strong>' . $t['class'] . '</strong>' . $t['type'];
}
echo '<strong>' . $t['function'] . '</strong>';
echo '(' . (empty($t['args']) ? '' : $this->htmlEncode($this->argumentsToString($t['args']))) . ')';
echo '</div>';
if ($hasCode) {
$this->renderSourceCode($t['file'], $t['line'], $this->maxTraceSourceLines);
}
echo "</td></tr>\n";
}
echo '</table>';
}
public function htmlEncode($text)
{
return htmlspecialchars($text, ENT_QUOTES, \Yii::$application->charset);
}
public function logException($exception)
{
$category = get_class($exception);
if ($exception instanceof HttpException) {
$category .= '\\' . $exception->statusCode;
} elseif ($exception instanceof \ErrorException) {
$category .= '\\' . $exception->getSeverity();
}
\Yii::error((string)$exception, $category);
}
public function clearOutput()
{
// the following manual level counting is to deal with zlib.output_compression set to On
for ($level = ob_get_level(); $level > 0; --$level) {
@ob_end_clean();
}
} }
/** /**
* Handles PHP execution errors such as warnings, notices. * @param \Exception $exception
*
* This method is implemented as a PHP error handler. It requires
* that constant YII_ENABLE_ERROR_HANDLER be defined true.
*
* This method will first raise an `error` event.
* If the error is not handled by any event handler, it will call
* {@link getErrorHandler errorHandler} to process the error.
*
* The application will be terminated by this method.
*
* @param integer $code the level of the error raised
* @param string $message the error message
* @param string $file the filename that the error was raised in
* @param integer $line the line number the error was raised at
*/ */
public function handleError($code, $message, $file, $line) public function renderAsText($exception)
{ {
throw new \ErrorException($message, 0, $code, $file, $line); if (YII_DEBUG) {
echo get_class($exception) . "\n";
echo $exception->getMessage() . ' (' . $exception->getFile() . ':' . $exception->getLine() . ")\n";
echo $exception->getTraceAsString();
} else {
echo get_class($exception) . "\n";
echo $exception->getMessage();
}
}
/**
* @param \Exception $exception
*/
public function renderAsHtml($exception)
{
$view = new View;
$view->owner = $this;
$name = !YII_DEBUG || $exception instanceof HttpException ? $this->errorView : $this->exceptionView;
$view->render($name, array(
'exception' => $exception,
));
} }
} }

26
framework/base/View.php

@ -64,7 +64,7 @@ class View extends Component
{ {
$file = $this->findViewFile($view); $file = $this->findViewFile($view);
if ($file !== false) { if ($file !== false) {
return $this->renderFile($file, $params); $this->renderFile($file, $params);
} else { } else {
throw new Exception("Unable to find the view file for view '$view'."); throw new Exception("Unable to find the view file for view '$view'.");
} }
@ -72,45 +72,30 @@ class View extends Component
public function renderFile($file, $params = array()) public function renderFile($file, $params = array())
{ {
return $this->renderFileInternal($file, $params); $this->renderFileInternal($file, $params);
} }
public function widget($class, $properties = array(), $returnOutput = false) public function widget($class, $properties = array())
{ {
if ($returnOutput) {
ob_start();
ob_implicit_flush(false);
$widget = $this->createWidget($class, $properties);
$widget->run();
return ob_get_clean();
} else {
$widget = $this->createWidget($class, $properties); $widget = $this->createWidget($class, $properties);
$widget->run(); $widget->run();
return $widget; return $widget;
} }
}
private $_widgetStack = array(); private $_widgetStack = array();
public function beginWidget($class, $properties = array()) public function beginWidget($class, $properties = array())
{ {
ob_start();
ob_implicit_flush(false);
$widget = $this->createWidget($class, $properties); $widget = $this->createWidget($class, $properties);
$this->_widgetStack[] = $widget; $this->_widgetStack[] = $widget;
return $widget; return $widget;
} }
public function endWidget($returnOutput = false) public function endWidget()
{ {
if (($widget = array_pop($this->_widgetStack)) !== null) { if (($widget = array_pop($this->_widgetStack)) !== null) {
$widget->run(); $widget->run();
if ($returnOutput) {
return ob_get_clean();
} else {
ob_end_clean();
return $widget; return $widget;
}
} else { } else {
throw new Exception("Unmatched beginWidget() and endWidget() calls."); throw new Exception("Unmatched beginWidget() and endWidget() calls.");
} }
@ -228,10 +213,7 @@ class View extends Component
protected function renderFileInternal($_file_, $_params_ = array()) protected function renderFileInternal($_file_, $_params_ = array())
{ {
extract($_params_, EXTR_OVERWRITE); extract($_params_, EXTR_OVERWRITE);
ob_start();
ob_implicit_flush(false);
require($_file_); require($_file_);
return ob_get_clean();
} }
public function findViewFile($view) public function findViewFile($view)

71
framework/views/error.php

@ -0,0 +1,71 @@
<?php
/**
* @var \Exception $exception
* @var \yii\base\ErrorHandler $owner
*/
$owner = $this->owner;
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php echo get_class($exception); ?></title>
<style type="text/css">
/*<![CDATA[*/
body {
font: normal 9pt "Verdana";
color: #000;
background: #fff;
}
h1 {
font: normal 18pt "Verdana";
color: #f00;
margin-bottom: .5em;
}
h2 {
font: normal 14pt "Verdana";
color: #800000;
margin-bottom: .5em;
}
h3 {
font: bold 11pt "Verdana";
}
p {
font: normal 9pt "Verdana";
color: #000;
}
.version {
color: gray;
font-size: 8pt;
border-top: 1px solid #aaa;
padding-top: 1em;
margin-bottom: 1em;
}
/*]]>*/
</style>
</head>
<body>
<h1><?php echo get_class($exception); ?></h1>
<h2><?php echo nl2br($owner->htmlEncode($exception->getMessage()))?> </h2>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
If you think this is a server error, please contact us.
</p>
<p>
Thank you.
</p>
<div class="version">
<?php echo date('Y-m-d H:i:s', time()); ?>
<?php echo YII_DEBUG ? $owner->versionInfo : ''; ?>
</div>
</body>
</html>

212
framework/views/exception.php

@ -0,0 +1,212 @@
<?php
/**
* @var \Exception $exception
* @var \yii\base\ErrorHandler $owner
*/
$owner = $this->owner;
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php echo get_class($exception); ?></title>
<style type="text/css">
/*<![CDATA[*/
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent;margin:0;padding:0;}
body{line-height:1;}
ol,ul{list-style:none;}
blockquote,q{quotes:none;}
blockquote:before,blockquote:after,q:before,q:after{content:none;}
:focus{outline:0;}
ins{text-decoration:none;}
del{text-decoration:line-through;}
table{border-collapse:collapse;border-spacing:0;}
body {
font: normal 9pt "Verdana";
color: #000;
background: #fff;
}
h1 {
font: normal 18pt "Verdana";
color: #f00;
margin-bottom: .5em;
}
h2 {
font: normal 14pt "Verdana";
color: #800000;
margin-bottom: .5em;
}
h3 {
font: bold 11pt "Verdana";
}
pre {
font: normal 11pt Menlo, Consolas, "Lucida Console", Monospace;
}
pre span.error {
display: block;
background: #fce3e3;
}
pre span.ln {
color: #999;
padding-right: 0.5em;
border-right: 1px solid #ccc;
}
pre span.error-ln {
font-weight: bold;
}
.container {
margin: 1em 4em;
}
.version {
color: gray;
font-size: 8pt;
border-top: 1px solid #aaa;
padding-top: 1em;
margin-bottom: 1em;
}
.message {
color: #000;
padding: 1em;
font-size: 11pt;
background: #f3f3f3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
margin-bottom: 1em;
line-height: 160%;
}
.source {
margin-bottom: 1em;
}
.code pre {
background-color: #ffe;
margin: 0.5em 0;
padding: 0.5em;
line-height: 125%;
border: 1px solid #eee;
}
.source .file {
margin-bottom: 1em;
font-weight: bold;
}
.traces {
margin: 2em 0;
}
.trace {
margin: 0.5em 0;
padding: 0.5em;
}
.trace.app {
border: 1px dashed #c00;
}
.trace .number {
text-align: right;
width: 2em;
padding: 0.5em;
}
.trace .content {
padding: 0.5em;
}
.trace .plus,
.trace .minus {
display: inline;
vertical-align: middle;
text-align: center;
border: 1px solid #000;
color: #000;
font-size: 10px;
line-height: 10px;
margin: 0;
padding: 0 1px;
width: 10px;
height: 10px;
}
.trace.collapsed .minus,
.trace.expanded .plus,
.trace.collapsed pre {
display: none;
}
.trace-file {
cursor: pointer;
padding: 0.2em;
}
.trace-file:hover {
background: #f0ffff;
}
/*]]>*/
</style>
</head>
<body>
<div class="container">
<h1><?php echo get_class($exception); ?></h1>
<p class="message">
<?php echo nl2br($owner->htmlEncode($exception->getMessage()))?>
</p>
<div class="source">
<p class="file">
<?php echo $owner->htmlEncode($exception->getFile()) . '(' . $exception->getLine() . ')'; ?>
</p>
<?php if (YII_DEBUG) $owner->renderSourceCode($exception->getFile(), $exception->getLine(), $owner->maxSourceLines); ?>
</div>
<?php if (YII_DEBUG): ?>
<div class="traces">
<h2>Stack Trace</h2>
<?php $owner->renderTrace($exception->getTrace()); ?>
</div>
<?php endif; ?>
<div class="version">
<?php echo date('Y-m-d H:i:s', time()); ?>
<?php echo YII_DEBUG ? $owner->versionInfo : ''; ?>
</div>
</div>
<script type="text/javascript">
/*<![CDATA[*/
var traceReg = new RegExp("(^|\\s)trace-file(\\s|$)");
var collapsedReg = new RegExp("(^|\\s)collapsed(\\s|$)");
var e = document.getElementsByTagName("div");
for(var j=0,len=e.length;j<len;j++){
if(traceReg.test(e[j].className)){
e[j].onclick = function(){
var trace = this.parentNode.parentNode;
if(collapsedReg.test(trace.className))
trace.className = trace.className.replace("collapsed", "expanded");
else
trace.className = trace.className.replace("expanded", "collapsed");
}
}
}
/*]]>*/
</script>
</body>
</html>
Loading…
Cancel
Save