corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-17 a212c53dc537ce66800b8e987fb18b1aab994bb4
src/Framework/ErrorHandler.php
@@ -5,6 +5,7 @@
namespace Framework;
use ErrorException;
use Throwable;
class ErrorHandler {
    public static function handleError(
@@ -16,4 +17,25 @@
        {
            throw new ErrorException($errstr,0, $errno, $errfile, $errline);
    }
    public static function handleException(Throwable $exception) {
        static $show_errors = true;
        if($exception instanceof Exceptions\PageNotFoundException) {
            http_response_code(404);
            $template = "404.php";
        } else {
            http_response_code(500);
            $template = "500.php";
        }
        if($show_errors) {
            ini_set("display_errors", "1");
        }else{
            ini_set("display_errors","0");
            ini_set("log_errors","1");
            require "views/$template";
        }
        throw $exception;
    }
}