error.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* @var $exception \yii\web\HttpException|\Exception */
  3. /* @var $handler \yii\web\ErrorHandler */
  4. if ($exception instanceof \yii\web\HttpException) {
  5. $code = $exception->statusCode;
  6. } else {
  7. $code = $exception->getCode();
  8. }
  9. $name = $handler->getExceptionName($exception);
  10. if ($name === null) {
  11. $name = 'Error';
  12. }
  13. if ($code) {
  14. $name .= " (#$code)";
  15. }
  16. if ($exception instanceof \yii\base\UserException) {
  17. $message = $exception->getMessage();
  18. } else {
  19. $message = 'An internal server error occurred.';
  20. }
  21. if (method_exists($this, 'beginPage')) {
  22. $this->beginPage();
  23. }
  24. ?>
  25. <!DOCTYPE html>
  26. <html>
  27. <head>
  28. <meta charset="utf-8" />
  29. <title><?= $handler->htmlEncode($name) ?></title>
  30. <style>
  31. body {
  32. font: normal 9pt "Verdana";
  33. color: #000;
  34. background: #fff;
  35. }
  36. h1 {
  37. font: normal 18pt "Verdana";
  38. color: #f00;
  39. margin-bottom: .5em;
  40. }
  41. h2 {
  42. font: normal 14pt "Verdana";
  43. color: #800000;
  44. margin-bottom: .5em;
  45. }
  46. h3 {
  47. font: bold 11pt "Verdana";
  48. }
  49. p {
  50. font: normal 9pt "Verdana";
  51. color: #000;
  52. }
  53. .version {
  54. color: gray;
  55. font-size: 8pt;
  56. border-top: 1px solid #aaa;
  57. padding-top: 1em;
  58. margin-bottom: 1em;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <h1><?= $handler->htmlEncode($name) ?></h1>
  64. <h2><?= nl2br($handler->htmlEncode($message)) ?></h2>
  65. <p>
  66. The above error occurred while the Web server was processing your request.
  67. </p>
  68. <p>
  69. Please contact us if you think this is a server error. Thank you.
  70. </p>
  71. <div class="version">
  72. <?= date('Y-m-d H:i:s') ?>
  73. </div>
  74. <?php if (method_exists($this, 'endBody')): ?>
  75. <?php $this->endBody() // to allow injecting code into body (mostly by Yii Debug Toolbar)?>
  76. <?php endif ?>
  77. </body>
  78. </html>
  79. <?php if (method_exists($this, 'endPage')): ?>
  80. <?php $this->endPage() ?>
  81. <?php endif ?>