mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-13 12:49:04 +08:00
@@ -8,9 +8,8 @@ if ($exception instanceof \yii\web\HttpException) {
|
||||
} else {
|
||||
$code = $exception->getCode();
|
||||
}
|
||||
if ($exception instanceof \yii\base\Exception) {
|
||||
$name = $exception->getName();
|
||||
} else {
|
||||
$name = $handler->getExceptionName($exception);
|
||||
if ($name === null) {
|
||||
$name = 'Error';
|
||||
}
|
||||
if ($code) {
|
||||
|
||||
@@ -12,13 +12,17 @@
|
||||
<meta charset="utf-8"/>
|
||||
|
||||
<title><?php
|
||||
$name = $handler->getExceptionName($exception);
|
||||
if ($exception instanceof \yii\web\HttpException) {
|
||||
echo (int) $exception->statusCode . ' ' . $handler->htmlEncode($exception->getName());
|
||||
} elseif ($exception instanceof \yii\base\Exception) {
|
||||
echo $handler->htmlEncode($exception->getName() . ' – ' . get_class($exception));
|
||||
echo (int) $exception->statusCode . ' ' . $handler->htmlEncode($name);
|
||||
} else {
|
||||
$name = $handler->getExceptionName($exception);
|
||||
if ($name !== null) {
|
||||
echo $handler->htmlEncode($name . ' – ' . get_class($exception));
|
||||
} else {
|
||||
echo $handler->htmlEncode(get_class($exception));
|
||||
}
|
||||
}
|
||||
?></title>
|
||||
|
||||
<style type="text/css">
|
||||
@@ -331,12 +335,15 @@ html,body{
|
||||
if ($exception instanceof \yii\web\HttpException) {
|
||||
echo '<span>' . $handler->createHttpStatusLink($exception->statusCode, $handler->htmlEncode($exception->getName())) . '</span>';
|
||||
echo ' – ' . $handler->addTypeLinks(get_class($exception));
|
||||
} elseif ($exception instanceof \yii\base\Exception) {
|
||||
echo '<span>' . $handler->htmlEncode($exception->getName()) . '</span>';
|
||||
} else {
|
||||
$name = $handler->getExceptionName($exception);
|
||||
if ($name !== null) {
|
||||
echo '<span>' . $handler->htmlEncode($name) . '</span>';
|
||||
echo ' – ' . $handler->addTypeLinks(get_class($exception));
|
||||
} else {
|
||||
echo '<span>' . $handler->htmlEncode(get_class($exception)) . '</span>';
|
||||
}
|
||||
}
|
||||
?></h1>
|
||||
<?php endif; ?>
|
||||
<h2><?= nl2br($handler->htmlEncode($exception->getMessage())) ?></h2>
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
<span class="arrow">↵</span>
|
||||
<h2>
|
||||
<span>Caused by:</span>
|
||||
<?php if ($exception instanceof \yii\base\Exception): ?>
|
||||
<span><?= $handler->htmlEncode($exception->getName()) ?></span> –
|
||||
<?php $name = $handler->getExceptionName($exception);
|
||||
if ($name !== null): ?>
|
||||
<span><?= $handler->htmlEncode($name) ?></span> –
|
||||
<?= $handler->addTypeLinks(get_class($exception)) ?>
|
||||
<?php else: ?>
|
||||
<span><?= $handler->htmlEncode(get_class($exception)) ?></span>
|
||||
|
||||
@@ -379,4 +379,17 @@ class ErrorHandler extends \yii\base\ErrorHandler
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human-readable exception name
|
||||
* @param \Exception $exception
|
||||
* @return string human-readable exception name or null if it cannot be determined
|
||||
*/
|
||||
public function getExceptionName($exception)
|
||||
{
|
||||
if ($exception instanceof \yii\base\Exception || $exception instanceof \yii\base\InvalidCallException || $exception instanceof \yii\base\InvalidParamException || $exception instanceof \yii\base\UnknownMethodException) {
|
||||
return $exception->getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user