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 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-03-11 21:55:08 +00:00
parent e7f8b1785a
commit 36b12888b2

View file

@ -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) {