fourth commit
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user