From: Jakob Cornell Date: Sun, 31 May 2026 17:15:50 +0000 (-0500) Subject: Use status bar for error reporting X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7b537e98b3cbf439c0e99f41c2c6dc292c8ae1e;p=ntbd-parcels.git Use status bar for error reporting --- diff --git a/main.js b/main.js index db52977..7fde9a3 100644 --- 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: "© OpenStreetMap"}, -); -tileLayer.addTo(map); + const tileLayer = L.tileLayer( + "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + {maxZoom: 19, attribution: "© 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; +}