filtragem de erros

This commit is contained in:
2025-08-04 04:46:10 -03:00
parent fb5931c99f
commit 4852973888

View File

@@ -23,13 +23,21 @@
</header>
</div>
<?php
set_error_handler(function ($severity, $message, $file, $line) {
throw new ErrorException($message, 0, $severity, $file, $line);
});
$page = filter_input(INPUT_GET, "pg", FILTER_VALIDATE_INT) ?: 1;
$comps = ["inicio.php", "escrever.php"];
$file = "componentes/" . $comps[$page - 1];
try {
$file = "componentes/" . $comps[$page - 1];
if (!file_exists($file)) {
http_response_code(404);
die("<p>Error 404, arquivo não encontrado</p>");
if (!file_exists($file)) {
http_response_code(404);
die("<p>Error 404, arquivo não encontrado</p>");
}
} catch (Exception $e) {
$file = "componentes/inicio.php";
}
require_once $file;
?>