Adopt StructuredError bubbling standard (observability producer) - #13
Merged
Conversation
Wrap internal errors with context preserving the native cause chain into
logs, and surface a client-safe { code, source, message } shape at the
edge — mirroring the standard already live on provider-platform.
- add local StructuredError (SDK does not export one): carries code +
source + native cause; toWire() projects the client-safe shape; static
from() wraps a raw error idempotently, preserving it as the cause.
- logger.error() flattens the cause chain (outer <- inner <- root) so a
wrapped error logs its full context, not just the outermost message.
- council-fetch throws StructuredError (COUNCIL_PLATFORM_HTTP_ERROR /
_UNREACHABLE); env config throws StructuredError (ENV_MISSING /
_INVALID_NETWORK).
- topology-refresh wraps failures as TOPOLOGY_REFRESH_FAILED and
broadcasts a client-safe error frame on the bus.
- network WS gains an additive { type: "error", error } frame (no
subprotocol bump: old SPAs drop unknown frames); 426 body structured.
- bus gains a structured-error channel (subscribeErrors/publishError).
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.
Adopts the StructuredError error-bubbling standard (already live on provider-platform / pay-platform) on network-dashboard-platform — the producer side of this coordinated pair. Errors are wrapped with context preserving the native cause chain into logs, and a client-safe
{ code, source, message }shape is what leaves the edge (here, the network WebSocket).The SDK does not export a
StructuredErrortype, so the shape is defined locally (src/error/structured-error.ts), matching the standard's contract.What changed
StructuredError(new, local): carriescode+source+ nativecause;toWire()projects the client-safe shape; idempotentstatic from()wraps a raw error while preserving it as the cause.error()now flattens the.causechain intoouter <- inner <- root, so a wrapped error logs its full context (mirrors provider-platform'sflattenCauses).StructuredError—COUNCIL_PLATFORM_HTTP_ERRORon non-OK,COUNCIL_PLATFORM_UNREACHABLE(cause preserved) on network/timeout.StructuredError(ENV_MISSING/ENV_INVALID_NETWORK).TOPOLOGY_REFRESH_FAILED(council error as cause → full chain in logs) and broadcasts a client-safe error frame on the bus.subscribeErrors/publishError).{ type: "error", error }frame. No subprotocol bump: it's a new frame type, so older SPAs drop it viaparseServerFramerather than mis-render — a platform-first deploy won't disconnect not-yet-updated clients. The 426 body is also structured.The
/public/rpcJSON-RPC error envelope (-32xxx) is left as-is — that's a protocol standard, not this service's own error shape.Consumer
network-dashboard reads
StructuredError.codefrom the new error frame and maps it to operator copy (its PR consumes this wire contract).Tests
deno check/lint/fmt/testgreen. New:StructuredError(wrap/idempotent/toWire), logger cause-chain flattening, topology-refresh error broadcast, WS error-frame delivery + unsubscribe-on-close. 46 tests pass.Version bump
0.1.13 → 0.1.14(own commit).