corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-20 5a22aad95225fb6f27fc61d8bcaf4511b71c4faa
commit | author | age
2ab29e 1 <?php
F 2
3 declare(strict_types= 1);
4
5 namespace Framework;
6
7 use ErrorException;
4ee40e 8 use Throwable;
2ab29e 9
F 10 class ErrorHandler {
11     public static function handleError(
12         int $errno,
13         string $errstr,
14         string $errfile,
15         int $errline
16         ): bool 
17         {
18             throw new ErrorException($errstr,0, $errno, $errfile, $errline);
19     }
4ee40e 20     public static function handleException(Throwable $exception) {
F 21     
22         if($exception instanceof Exceptions\PageNotFoundException) {
23             http_response_code(404);
24             $template = "404.php";
25         } else {
26             http_response_code(500);
27             $template = "500.php";
28         }
29     
5a22aa 30         if($_ENV["SHOW_ERRORS"]) {
4ee40e 31             ini_set("display_errors", "1");
F 32         }else{
33             ini_set("display_errors","0");
34             ini_set("log_errors","1");
35             require "views/$template";
36         }
37     
38         throw $exception;
39     }
2ab29e 40 }