1 | <?php |
||
5 | class ErrorHandler |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * Register the default error handling |
||
10 | */ |
||
11 | public static function register() |
||
18 | |||
19 | /** |
||
20 | * Default Exception handler to show a nice user message before dieing |
||
21 | * |
||
22 | * The exception is logged to the error log |
||
23 | * |
||
24 | * @param \Throwable $e |
||
25 | */ |
||
26 | public static function fatalException($e) |
||
51 | |||
52 | /** |
||
53 | * Convenience method to display an error message for the given Exception |
||
54 | * |
||
55 | * @param \Throwable $e |
||
56 | * @param string $intro |
||
57 | */ |
||
58 | public static function showExceptionMsg($e, $intro = 'Error!') |
||
64 | |||
65 | /** |
||
66 | * Default error handler to convert old school warnings, notices, etc to exceptions |
||
67 | * |
||
68 | * You should not need to call this directly! |
||
69 | * |
||
70 | * @param int $errno |
||
71 | * @param string $errstr |
||
72 | * @param string $errfile |
||
73 | * @param int $errline |
||
74 | * @return bool |
||
75 | * @throws \ErrorException |
||
76 | */ |
||
77 | public static function errorConverter($errno, $errstr, $errfile, $errline) |
||
86 | |||
87 | /** |
||
88 | * Log the given exception to the error log |
||
89 | * |
||
90 | * @param \Throwable $e |
||
91 | * @return bool false if the logging failed |
||
92 | */ |
||
93 | public static function logException($e) |
||
106 | |||
107 | /** |
||
108 | * Checks the the stacktrace for plugin files |
||
109 | * |
||
110 | * @param \Throwable $e |
||
111 | * @return false|string |
||
112 | */ |
||
113 | protected static function guessPlugin($e) |
||
133 | } |
||
134 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: