Map structured errors to operator copy via a WS banner#22
Merged
Conversation
The dashboard's only backend link is the network WebSocket, so structured
errors ride it too — from two sources, both surfaced through one mapper:
- transport errors (connect fail / drop / reconnect), previously a silent
console.warn plus an unwired hardcoded banner; and
- { type: "error" } frames the backend now pushes over the socket (e.g. a
failed council-platform topology refresh).
- add lib/error-copy.ts: shape-agnostic errorCopy() mirroring moonlight-pay
friendlyError — known code -> copy, else a safe server message, else a
generic fallback. Reads .code regardless of which backend produced it.
- network-events: add the StructuredError type + additive { type: "error" }
frame; parseServerFrame validates it.
- ws-client: onError handler; switch over frame type.
- dom.renderError now DISPLAYS the (mapped) message instead of a hardcoded
string, keeping the generic sentence only as an empty-message fallback.
- app.ts: a connection/degraded-data banner wired to both transport status
and backend error frames through the mapper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consumer side of the coordinated StructuredError adoption (pairs with network-dashboard-platform#13). The dashboard's only backend link is the network WebSocket, so structured errors ride it too — the "structured-error path" here is the WS payload, not an HTTP body. Two error sources, both surfaced through one shape-agnostic mapper:
console.warnplus a hardcoded generic banner that wasn't even wired up.{ type: "error" }frames the backend now pushes over the socket (e.g. a failed council-platform topology refresh) — the connection is still live but some data may be degraded.What changed
lib/error-copy.ts(new):errorCopy()mirroring moonlight-pay'sfriendlyError— knowncode→ copy, else a safe server message (guarded byisSafeSentence), else a generic fallback. Reads.coderegardless of which backend produced it, so a council-platform code bubbled through network-dashboard-platform maps the same as a native one.StructuredErrortype + the additive{ type: "error" }frame;parseServerFramevalidates it (mirrors the backend, no subprotocol bump).onErrorhandler;onmessageswitches over frame type.closed/not-configured → mapped copy; cleared onopen) and backend error frames, all through the mapper.No new REST path / CSP / config changes — errors ride the existing WebSocket. Council-platform failures reach the SPA via the backend's
TOPOLOGY_REFRESH_FAILEDframe; the mapper stays shape-agnostic so any upstream code maps.Tests
deno check/lint/fmt/ dev+prodbuild/testgreen. New:errorCopymapper (known/unknown code, safe-message passthrough, unsafe-message rejection, transport codes, code-over-message), error-frame parsing, andrenderErrornow-displays-mapped-copy + fallback. 25 tests pass.Version bump
0.2.15 → 0.2.16(own commit).Merge order
Merge after network-dashboard-platform#13 (platform anchors the wire contract).