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:
parent
e7f8b1785a
commit
36b12888b2
1 changed files with 7 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue