commit | author | age
|
15e03a
|
1 |
<?php |
F |
2 |
|
|
3 |
declare(strict_types= 1); |
|
4 |
|
|
5 |
namespace Framework; |
|
6 |
|
|
7 |
use ErrorException; |
|
8 |
use Throwable; |
|
9 |
|
|
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 |
} |
|
20 |
public static function handleException(Throwable $exception) { |
|
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 |
|
|
30 |
if($_ENV["SHOW_ERRORS"]) { |
|
31 |
ini_set("display_errors", "1"); |
|
32 |
}else{ |
|
33 |
ini_set("display_errors","0"); |
|
34 |
ini_set("log_errors","1"); |
|
35 |
require dirname(__DIR__,2) . "/views/$template"; |
|
36 |
} |
|
37 |
|
|
38 |
throw $exception; |
|
39 |
} |
|
40 |
} |