[object Object]

← back to Brand Selector Viewer

Add error handling to output-viewer fetch so missing/file:// loads show a helpful message instead of failing silently

01d9cf8b6552f957b5cdffd07036d1554d850d56 · 2026-05-18 17:40:17 -0700 · Steve

Files touched

Diff

commit 01d9cf8b6552f957b5cdffd07036d1554d850d56
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon May 18 17:40:17 2026 -0700

    Add error handling to output-viewer fetch so missing/file:// loads show a helpful message instead of failing silently
---
 horsemen.html | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/horsemen.html b/horsemen.html
index 565c012..a104db5 100644
--- a/horsemen.html
+++ b/horsemen.html
@@ -513,11 +513,17 @@
     const t = e.target.closest("[data-view]");
     if (!t) return;
     const k = t.dataset.view;
-    const r = await fetch(sources[k]);
-    const text = await r.text();
     document.getElementById("modal-title").textContent = titles[k];
-    document.getElementById("modal-body").textContent = text;
     document.getElementById("modal").classList.add("show");
+    try {
+      const r = await fetch(sources[k]);
+      if (!r.ok) throw new Error(`HTTP ${r.status}`);
+      document.getElementById("modal-body").textContent = await r.text();
+    } catch (err) {
+      document.getElementById("modal-body").textContent =
+        `Could not load ${sources[k]} — ${err.message}.\n` +
+        `Serve this folder over HTTP (file:// blocks fetch) and confirm the file exists.`;
+    }
   });
   document.getElementById("close").onclick = () => document.getElementById("modal").classList.remove("show");
   document.getElementById("copy").onclick = async () => {

← 53e8749 Remove unused index param from card render map  ·  back to Brand Selector Viewer  ·  fix: add rel=noopener noreferrer to all target=_blank links 2f04650 →