Improve error handling in page_renderer.php
This commit is contained in:
@@ -4,9 +4,10 @@ class SPLPageRenderer {
|
|||||||
public function renderCouncilPage($config, $candidates) {
|
public function renderCouncilPage($config, $candidates) {
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
set_error_handler(function($errno, $errstr, $errfile, $errline) {
|
$didError = false;
|
||||||
// Clear any output if an error occurred
|
|
||||||
ob_clean();
|
set_error_handler(function($errno, $errstr, $errfile, $errline) use(&$didError) {
|
||||||
|
$didError = true;
|
||||||
error_log("Error: $errstr in $errfile on line $errline");
|
error_log("Error: $errstr in $errfile on line $errline");
|
||||||
return true; // Prevent default error handling
|
return true; // Prevent default error handling
|
||||||
});
|
});
|
||||||
@@ -17,8 +18,8 @@ class SPLPageRenderer {
|
|||||||
|
|
||||||
$content = ob_get_clean();
|
$content = ob_get_clean();
|
||||||
|
|
||||||
// Explictly return null if we didn't generate any content
|
// Explictly return null if we didn't generate any content or if there was an error
|
||||||
if (!empty($content)) {
|
if (!empty($content) && !$didError) {
|
||||||
return $content;
|
return $content;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user