error handler - dump caught exception/fatal error to debug log if running under CLI SAPI

This commit is contained in:
Andrew Dolgov
2025-05-03 08:18:16 +03:00
parent 4cda1da5c0
commit 01159fa6f8

View File

@@ -49,6 +49,11 @@ function ttrss_error_handler(int $errno, string $errstr, string $file, int $line
$context = format_backtrace(debug_backtrace());
$errstr = truncate_middle($errstr, 16384, " (...) ");
if (php_sapi_name() == 'cli' && class_exists("Debug")) {
Debug::log("!! Exception: $errstr ($file:$line)");
Debug::log($context);
}
if (class_exists("Logger"))
return Logger::log_error((int)$errno, $errstr, $file, (int)$line, $context);
else
@@ -70,6 +75,11 @@ function ttrss_fatal_handler(): bool {
$file = substr(str_replace(dirname(__DIR__), "", $file), 1);
if (php_sapi_name() == 'cli' && class_exists("Debug")) {
Debug::log("!! Fatal error: $errstr ($file:$line)");
Debug::log($context);
}
if (class_exists("Logger"))
return Logger::log_error((int)$errno, $errstr, $file, (int)$line, $context);
}