error.php 2.04 KB
Newer Older
1 2
<?php
/**
Thiago Talma committed
3
 * @var \yii\web\HttpException|\Exception $exception
4
 * @var \yii\web\ErrorHandler $handler
5
 */
Qiang Xue committed
6
if ($exception instanceof \yii\web\HttpException) {
7
    $code = $exception->statusCode;
Qiang Xue committed
8
} else {
9
    $code = $exception->getCode();
Qiang Xue committed
10
}
11 12
$name = $handler->getExceptionName($exception);
if ($name === null) {
13
    $name = 'Error';
Qiang Xue committed
14 15
}
if ($code) {
16
    $name .= " (#$code)";
Qiang Xue committed
17 18 19
}

if ($exception instanceof \yii\base\UserException) {
20
    $message = $exception->getMessage();
Qiang Xue committed
21
} else {
22
    $message = 'An internal server error occurred.';
Qiang Xue committed
23
}
24 25 26 27

if (method_exists($this, 'beginPage')) {
    $this->beginPage();
}
28 29 30 31
?>
<!DOCTYPE html>
<html>
<head>
32 33
    <meta charset="utf-8" />
    <title><?= $handler->htmlEncode($name) ?></title>
34

35 36 37 38 39 40
    <style>
        body {
            font: normal 9pt "Verdana";
            color: #000;
            background: #fff;
        }
41

42 43 44 45 46
        h1 {
            font: normal 18pt "Verdana";
            color: #f00;
            margin-bottom: .5em;
        }
47

48 49 50 51 52
        h2 {
            font: normal 14pt "Verdana";
            color: #800000;
            margin-bottom: .5em;
        }
53

54 55 56
        h3 {
            font: bold 11pt "Verdana";
        }
57

58 59 60 61
        p {
            font: normal 9pt "Verdana";
            color: #000;
        }
62

63 64 65 66 67 68 69 70
        .version {
            color: gray;
            font-size: 8pt;
            border-top: 1px solid #aaa;
            padding-top: 1em;
            margin-bottom: 1em;
        }
    </style>
71 72 73
</head>

<body>
74 75 76 77 78 79 80 81 82 83 84
    <h1><?= $handler->htmlEncode($name) ?></h1>
    <h2><?= nl2br($handler->htmlEncode($message)) ?></h2>
    <p>
        The above error occurred while the Web server was processing your request.
    </p>
    <p>
        Please contact us if you think this is a server error. Thank you.
    </p>
    <div class="version">
        <?= date('Y-m-d H:i:s', time()) ?>
    </div>
85 86 87 88 89
    <?php
    if (method_exists($this, 'endBody')) {
        $this->endBody(); // to allow injecting code into body (mostly by Yii Debug Toolbar)
    }
    ?>
90 91
</body>
</html>
92 93 94
<?php
if (method_exists($this, 'endPage')) {
    $this->endPage();
Thiago Talma committed
95
}