Core/ErrorHandler

* do not handle errors outside of the registered handlers
 * always handle all errors otherwise they get stored for error_get_last
 * always print errors to CLI
 * shutdown function handler should not be picky about what errors it gets to report
 * removed some mostly unused error strings
This commit is contained in:
Sarjuuk
2024-06-24 16:50:10 +02:00
parent e614f415a9
commit 79764ced60
5 changed files with 52 additions and 68 deletions

View File

@@ -309,6 +309,20 @@ abstract class CLI
flush();
}
public static function logLevelFromE(int $phpError) : int
{
if ($phpError & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR))
return self::LOG_ERROR;
if ($phpError & (E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE | E_CORE_WARNING | E_COMPILE_WARNING))
return self::LOG_WARN;
if ($phpError & (E_STRICT | E_NOTICE | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED))
return self::LOG_INFO;
return self::LOG_BLANK;
}
private static function purgeEscapes(string $msg) : string
{
return preg_replace(["/\e\[[\d;]+[mK]/", "/\e\[\d+G/"], ['', "\n"], $msg);