Garage API : gestion d'erreurs robuste (JSON garanti)
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:
percoandClaude Sonnet 4.6 committed 2026-05-11 17:31:29 +02:00
1 parent 7cacf4bdf5
commit 5ac4e51efb
2 files changed
+14 -2

No files matched your search

+2 -1
View File
@@ -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()]));
}
?>