fix(api): report a missing PDO SQLite driver with a clear message

On bare Windows PHP installs the pdo_sqlite extension is often
disabled; wrap the PDO connection so the failure surfaces as an
actionable error instead of a bare driver exception.
This commit is contained in:
BlackAngelTV committed 2026-09-16 14:35:53 +02:00
1 parent 83933d0621
commit f2b8c9c5e6
1 file changed
+12 -1
+12 -1
View File
@@ -52,7 +52,18 @@ function fws_bugs_db(): PDO
mkdir($dir, 0775, true);
}
$pdo = new PDO('sqlite:' . $dir . '/fws_bugs.sqlite');
try {
$pdo = new PDO('sqlite:' . $dir . '/fws_bugs.sqlite');
} catch (Throwable $e) {
/* Driver PDO SQLite absent (cas fréquent : WAMP/XAMPP où pdo_sqlite
et sqlite3 sont à activer dans php.ini). Message clair au lieu d'un
crash avec stack trace. */
throw new RuntimeException(
'Extension PDO SQLite indisponible : activez "extension=pdo_sqlite" et "extension=sqlite3" dans php.ini.',
0,
$e
);
}
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);