loader: warn when links.json parses fail instead of silently using example
Validate links data / validate (push) Has been cancelled

This commit is contained in:
Joel Brock
2026-05-28 07:56:53 -07:00
parent 23305ab1da
commit ffd1c24b6c
+9 -1
View File
@@ -712,7 +712,15 @@
try {
const res = await fetch(src, { cache: "no-cache" });
if (!res.ok) { lastErr = new Error(`${src}: HTTP ${res.status}`); continue; }
return await res.json();
try {
return await res.json();
} catch (parseErr) {
// File loaded but JSON is malformed — surface this loudly instead of
// silently falling back to the next source.
console.warn(`[dlstack] ${src} loaded but failed to parse — falling back. Fix the JSON to see your content.`, parseErr);
lastErr = new Error(`${src}: invalid JSON — ${parseErr.message}`);
continue;
}
} catch (err) { lastErr = err; }
}
throw lastErr || new Error("No data file found.");