progetto fatto precedentemente adattato al framework creato con il corso
filippo.bertilotti
2024-06-10 86a7fdf7157d24fa53a871956578ab3cd31ed699
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
 
declare(strict_types= 1);
 
namespace Framework;
 
use ErrorException;
use Throwable;
 
class ErrorHandler {
    public static function handleError(
        int $errno,
        string $errstr,
        string $errfile,
        int $errline
        ): bool 
        {
            throw new ErrorException($errstr,0, $errno, $errfile, $errline);
    }
    public static function handleException(Throwable $exception) {
    
        if($exception instanceof Exceptions\PageNotFoundException) {
            http_response_code(404);
            $template = "404.php";
        } else {
            http_response_code(500);
            $template = "500.php";
        }
    
        if($_ENV["SHOW_ERRORS"]) {
            ini_set("display_errors", "1");
        }else{
            ini_set("display_errors","0");
            ini_set("log_errors","1");
            require dirname(__DIR__,2) . "/views/$template";
        }
    
        throw $exception;
    }
}