fix(web): error handling on discard and history toggle

- LabDraft.tsx discard button: chain .catch to surface a failed discard in
  the existing error banner instead of an unhandled rejection.
- LabDraw.tsx toggleHistory: wrap the marker-history fetch in try/catch so a
  failed request silently no-ops (the row just doesn't expand) rather than
  throwing unhandled from the click handler.
This commit is contained in:
marcuspaico
2026-08-17 16:17:03 -07:00
parent e81d07975a
commit a9256a765f
2 changed files with 19 additions and 3 deletions

View File

@@ -80,7 +80,18 @@ export function LabDraft() {
<button disabled={busy || !collectedDate || markers.length === 0} onClick={confirm}>
{busy ? "Saving…" : `Confirm ${markers.length} markers`}
</button>
<button className="danger" onClick={() => id && api.discardDraft(id).then(() => nav("/labs"))}>Discard</button>
<button
className="danger"
onClick={() =>
id &&
api
.discardDraft(id)
.then(() => nav("/labs"))
.catch((e) => setError(e instanceof Error ? e.message : "discard failed"))
}
>
Discard
</button>
</div>
)}
</section>