Garage API : gestion d'erreurs robuste (JSON garanti)
Deploy to Pacha Family / deploy (push) Failing after 3s
Deploy to Pacha Family / deploy (push) Failing after 3s
- set_exception_handler global : toute exception PDO retourne du JSON au lieu d'une page HTML qui casse le JSON.parse côté client - gOk() : JSON_INVALID_UTF8_SUBSTITUTE pour données UTF-8 corrompues, vérification du retour de json_encode - db.php die() : retourne JSON au lieu de texte brut Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7cacf4bdf5
commit
5ac4e51efb
+2
-1
@@ -35,6 +35,7 @@ try {
|
||||
);
|
||||
$pdo->exec("SET collation_connection = utf8mb4_general_ci");
|
||||
} catch (\PDOException $e) {
|
||||
die("Erreur connexion BDD famille : " . $e->getMessage());
|
||||
if (!headers_sent()) { header('Content-Type: application/json'); http_response_code(500); }
|
||||
die(json_encode(['ok' => false, 'error' => 'Erreur BDD : ' . $e->getMessage()]));
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user