Commit 7511de6c by Carsten Brandt

added errorInfo to exception views

parent a2aa20f1
...@@ -42,8 +42,11 @@ class ErrorHandler extends \yii\base\ErrorHandler ...@@ -42,8 +42,11 @@ class ErrorHandler extends \yii\base\ErrorHandler
$message .= $this->formatMessage(" '" . get_class($exception) . "'", [Console::BOLD, Console::FG_BLUE]) $message .= $this->formatMessage(" '" . get_class($exception) . "'", [Console::BOLD, Console::FG_BLUE])
. " with message " . $this->formatMessage("'{$exception->getMessage()}'", [Console::BOLD]) //. "\n" . " with message " . $this->formatMessage("'{$exception->getMessage()}'", [Console::BOLD]) //. "\n"
. "\n\nin " . dirname($exception->getFile()) . DIRECTORY_SEPARATOR . $this->formatMessage(basename($exception->getFile()), [Console::BOLD]) . "\n\nin " . dirname($exception->getFile()) . DIRECTORY_SEPARATOR . $this->formatMessage(basename($exception->getFile()), [Console::BOLD])
. ':' . $this->formatMessage($exception->getLine(), [Console::BOLD, Console::FG_YELLOW]) . "\n\n" . ':' . $this->formatMessage($exception->getLine(), [Console::BOLD, Console::FG_YELLOW]) . "\n";
. $this->formatMessage("Stack trace:\n", [Console::BOLD]) . $exception->getTraceAsString(); if ($exception instanceof \yii\db\Exception && !empty($exception->errorInfo)) {
$message .= "\n" . $this->formatMessage("Error Info:\n", [Console::BOLD]) . print_r($exception->errorInfo, true);
}
$message .= "\n" . $this->formatMessage("Stack trace:\n", [Console::BOLD]) . $exception->getTraceAsString();
} else { } else {
$message = $this->formatMessage('Error: ') . $exception->getMessage(); $message = $this->formatMessage('Error: ') . $exception->getMessage();
} }
......
...@@ -87,6 +87,9 @@ html,body{ ...@@ -87,6 +87,9 @@ html,body{
font-size: 20px; font-size: 20px;
line-height: 1.25; line-height: 1.25;
} }
.header pre{
margin: 10px 0;
}
/* previous exceptions */ /* previous exceptions */
.header .previous{ .header .previous{
...@@ -104,8 +107,8 @@ html,body{ ...@@ -104,8 +107,8 @@ html,body{
filter: progid:DXImageTransform.Microsoft.BasicImage(mirror=1); filter: progid:DXImageTransform.Microsoft.BasicImage(mirror=1);
font-size: 26px; font-size: 26px;
position: absolute; position: absolute;
margin-top: -5px; margin-top: -3px;
margin-left: -25px; margin-left: -30px;
color: #e51717; color: #e51717;
} }
.header .previous h2{ .header .previous h2{
...@@ -130,6 +133,10 @@ html,body{ ...@@ -130,6 +133,10 @@ html,body{
font-size: 14px; font-size: 14px;
color: #aaa; color: #aaa;
} }
.header .previous pre{
font-size: 14px;
margin: 10px 0;
}
/* call stack */ /* call stack */
.call-stack{ .call-stack{
...@@ -348,6 +355,10 @@ html,body{ ...@@ -348,6 +355,10 @@ html,body{
<?php endif; ?> <?php endif; ?>
<h2><?= nl2br($handler->htmlEncode($exception->getMessage())) ?></h2> <h2><?= nl2br($handler->htmlEncode($exception->getMessage())) ?></h2>
<?php if ($exception instanceof \yii\db\Exception && !empty($exception->errorInfo)) {
echo '<pre>Error Info: ' . print_r($exception->errorInfo, true) . '</pre>';
} ?>
<?= $handler->renderPreviousExceptions($exception) ?> <?= $handler->renderPreviousExceptions($exception) ?>
</div> </div>
......
...@@ -18,5 +18,8 @@ ...@@ -18,5 +18,8 @@
</h2> </h2>
<h3><?= nl2br($handler->htmlEncode($exception->getMessage())) ?></h3> <h3><?= nl2br($handler->htmlEncode($exception->getMessage())) ?></h3>
<p>in <span class="file"><?= $exception->getFile() ?></span> at line <span class="line"><?= $exception->getLine() ?></span></p> <p>in <span class="file"><?= $exception->getFile() ?></span> at line <span class="line"><?= $exception->getLine() ?></span></p>
<?php if ($exception instanceof \yii\db\Exception && !empty($exception->errorInfo)) {
echo '<pre>Error Info: ' . print_r($exception->errorInfo, true) . '</pre>';
} ?>
<?= $handler->renderPreviousExceptions($exception) ?> <?= $handler->renderPreviousExceptions($exception) ?>
</div> </div>
...@@ -127,6 +127,9 @@ class ErrorHandler extends \yii\base\ErrorHandler ...@@ -127,6 +127,9 @@ class ErrorHandler extends \yii\base\ErrorHandler
} }
if (YII_DEBUG) { if (YII_DEBUG) {
$array['stack-trace'] = explode("\n", $exception->getTraceAsString()); $array['stack-trace'] = explode("\n", $exception->getTraceAsString());
if ($exception instanceof \yii\db\Exception) {
$array['error-info'] = $this->errorInfo;
}
} }
if (($prev = $exception->getPrevious()) !== null) { if (($prev = $exception->getPrevious()) !== null) {
$array['previous'] = $this->convertExceptionToArray($prev); $array['previous'] = $this->convertExceptionToArray($prev);
...@@ -169,7 +172,7 @@ class ErrorHandler extends \yii\base\ErrorHandler ...@@ -169,7 +172,7 @@ class ErrorHandler extends \yii\base\ErrorHandler
$page = $this->htmlEncode(strtolower(str_replace('\\', '-', $class))); $page = $this->htmlEncode(strtolower(str_replace('\\', '-', $class)));
$url = "http://www.yiiframework.com/doc-2.0/$page.html"; $url = "http://www.yiiframework.com/doc-2.0/$page.html";
if (isset($method)) { if (isset($method)) {
$url .= "#$method-detail"; $url .= "#$method()-detail";
} }
return '<a href="' . $url . '" target="_blank">' . $text . '</a>'; return '<a href="' . $url . '" target="_blank">' . $text . '</a>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment