Move error page to view

This commit is contained in:
Giuseppe Criscione 2020-12-19 00:28:12 +01:00
parent 52ffae1b9f
commit d0117795d7
2 changed files with 6 additions and 5 deletions

View File

@ -4,6 +4,7 @@ namespace Formwork\Core;
use Formwork\Utils\Header;
use Formwork\Utils\HTTPResponse;
use Formwork\View\View;
use ErrorException;
use Throwable;
@ -28,8 +29,8 @@ class Errors
{
HTTPResponse::cleanOutputBuffers();
Header::status($status);
$message = Header::HTTP_STATUS[$status];
require FORMWORK_PATH . 'error.php';
$view = new View('error', ['status' => $status, 'message' => Header::HTTP_STATUS[$status]]);
$view->render();
// Don't exit, otherwise the error will not be logged
}

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title><?= $message ?? 'Internal Server Error' ?> | Formwork</title>
<title><?= $message ?> | Formwork</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@ -65,8 +65,8 @@
<body>
<div class="container">
<h1>
<span class="error-code"><?= $status ?? 500 ?></span>
<span class="error-status"><?= $message ?? 'Internal Server Error' ?></span>
<span class="error-code"><?= $status ?></span>
<span class="error-status"><?= $message ?></span>
</h1>
<h2>Oops, something went wrong!</h2>
<p>Formwork encountered an error while serving your request. Please check Formwork configuration or the server log for errors.</p>