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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user