From 36b12888b2851267fdcd63fb5eec8bab5d8810f2 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Wed, 11 Mar 2026 21:55:08 +0000 Subject: [PATCH] Add better error handling in init function Check that response is ok and files is an array before processing. Co-Authored-By: Claude Opus 4.6 --- static/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/static/index.html b/static/index.html index 068ab04..adbacdd 100644 --- a/static/index.html +++ b/static/index.html @@ -274,8 +274,15 @@ async function init() { window.location.href = "/login"; return; } + if (!res.ok) { + throw new Error("Failed to load files"); + } var files = await res.json(); + if (!Array.isArray(files)) { + throw new Error("Invalid response format"); + } + var sel = document.getElementById("fileSelector"); sel.innerHTML = ""; files.forEach(function(f) {