fourth commit

This commit is contained in:
2026-06-12 21:26:30 +07:00
parent 33c28ec0d4
commit c150df3dc2
+16
View File
@@ -3,6 +3,22 @@
// config/helpers.php — Shared utility functions
// ============================================================
/**
* Global exception handler to return JSON on fatal errors.
*/
set_exception_handler(function(Throwable $e) {
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
http_response_code(500);
echo json_encode([
'error' => 'Internal Server Error',
'message' => $e->getMessage(),
'file' => basename($e->getFile()),
'line' => $e->getLine()
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
});
/**
* Set JSON response headers and output data.
*/