From a133a5a49dcc151aaada3be2e8752be3bbc57121 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Mon, 3 Aug 2026 14:18:48 -0500 Subject: [PATCH] index.php: catch bootstrap exceptions and render a non-fatal warning Per the spec's error-handling section, all exceptions must be caught at the top of index.php's bootstrap path so a single bad page (CurlError, JsonData, ApiValidation, ApiKeyMissing, LogEntryIncomplete) does not take down the whole UI. The page now renders whatever data is in the DB plus a warning banner with the exception message (htmlspecialchars-escaped to avoid XSS). On the first-run backfill path, the redirect is still emitted inside the try block so the success path is unchanged. --- index.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index b5cbb60..de6eb0d 100644 --- a/index.php +++ b/index.php @@ -13,15 +13,22 @@ require_once __DIR__ . '/config.php'; require_once __DIR__ . '/functions.php'; -if (dbNew()) { - foreach (USER_KEYS as $key => $value) { - backfillUserLogs($key); - } - header('Location: /'); -} else { - foreach (USER_KEYS as $key => $value) { - syncUserLogs($key); +$bootstrapWarning = null; + +try { + if (dbNew()) { + foreach (USER_KEYS as $key => $value) { + backfillUserLogs($key); + } + header('Location: /'); + exit; + } else { + foreach (USER_KEYS as $key => $value) { + syncUserLogs($key); + } } +} catch (Exception $e) { + $bootstrapWarning = $e->getMessage(); } ?> @@ -45,6 +52,10 @@ if (dbNew()) {

Torn Vault Tracker

+ +
Warning: failed to fetch latest logs from Torn — showing cached data. ()
+ +

Transactions