]> jcornell.net Git - ntbd-parcels.git/commitdiff
Use status bar for error reporting
authorJakob Cornell <jakob+gpg@jcornell.net>
Sun, 31 May 2026 17:15:50 +0000 (12:15 -0500)
committerJakob Cornell <jakob+gpg@jcornell.net>
Sun, 31 May 2026 17:15:50 +0000 (12:15 -0500)
main.js

diff --git a/main.js b/main.js
index db529775cc8482580585ac38df532dcf9cc766be..7fde9a3d49e384d8c2cf4cbb335c923839a73f49 100644 (file)
--- a/main.js
+++ b/main.js
@@ -21,6 +21,7 @@ function transposeCoordinates(coordList) {
        )));
 }
 
+const map = L.map("map");
 const statusSpan = document.querySelector("#status > span");
 const progressBar = document.querySelector("#status > progress");
 
@@ -46,7 +47,7 @@ async function asyncMain() {
                        localStorage[PARCEL_LOAD_KEY] = "1";
                } else {
                        console.error(geoJsonResponse);
-                       alert("Parcel data request failed");
+                       throw new Error("Parcel data request failed");
                }
        }
 
@@ -120,18 +121,22 @@ async function asyncMain() {
        statusSpan.innerText = "ready";
 }
 
-document.getElementById("picked-zones").innerText = [...PICK_ZONINGS].join(", ");
-document.getElementById("lot-size").innerText =
-       `${MIN_LOT_SIZE_ACRES} to ${MAX_LOT_SIZE_ACRES} acres`;
+try {
+       document.getElementById("picked-zones").innerText = [...PICK_ZONINGS].join(", ");
+       document.getElementById("lot-size").innerText =
+               `${MIN_LOT_SIZE_ACRES} to ${MAX_LOT_SIZE_ACRES} acres`;
 
-const map = L.map("map");
-const tileLayer = L.tileLayer(
-       "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
-       {maxZoom: 19, attribution: "&copy; OpenStreetMap"},
-);
-tileLayer.addTo(map);
+       const tileLayer = L.tileLayer(
+               "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
+               {maxZoom: 19, attribution: "&copy; OpenStreetMap"},
+       );
+       tileLayer.addTo(map);
 
-// Snap to a view of Madison.
-map.setView([43.073051, -89.401230], 13);
+       // Snap to a view of Madison.
+       map.setView([43.073051, -89.401230], 13);
 
-asyncMain();
+       await asyncMain();
+} catch (error) {
+       statusSpan.innerText = "error, see console";
+       throw error;
+}