Improve logging and error handling (#3059)

* refactor: logging and errror handling
This commit is contained in:
Dag 2022-10-16 17:55:43 +02:00 committed by GitHub
parent e21394d2d3
commit ffbc107687
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 143 additions and 93 deletions

View file

@ -16,9 +16,9 @@ final class RssBridge
} catch (\Throwable $e) {
Logger::error('Exception in main', ['e' => $e]);
http_response_code(500);
print render('error.html.php', [
'message' => create_sane_exception_message($e),
'stacktrace' => create_sane_stacktrace($e),
print render(__DIR__ . '/../templates/error.html.php', [
'message' => create_sane_exception_message($e),
'trace' => trace_from_exception($e),
]);
}
}
@ -38,6 +38,7 @@ final class RssBridge
return false;
}
$text = sprintf('%s at %s line %s', $message, trim_path_prefix($file), $line);
// Drop the current frame
Logger::warning($text);
if (Debug::isEnabled()) {
print sprintf('<pre>%s</pre>', $text);