fix: consume provider-platform StructuredError, map codes to operator copy#40
Merged
Conversation
…tor copy Replaces provider-console's string-matching / bare-status / silent-swallow handling of provider-platform errors with a code-driven mapper. - src/lib/errors.ts: StructuredError type + ConsoleError + operatorMessage mapper (code -> operator copy; unknown code -> safe body message -> generic) + platformError(res, context). Mirrors moonlight-pay friendlyError, adapted to operator copy. (moonlight-sdk v0.11.1 exports no StructuredError type, so it's console-local.) - src/lib/api.ts: every dashboard/auth/bundle error response now throws a ConsoleError with the mapped message + code, dropping the bare-status and body.message-or-generic patterns; checkMembershipStatus surfaces the error instead of silently returning PENDING. - page.ts / home.ts: background membership checks log the failure for the operator instead of swallowing it silently.
Extends the structured-error work to the core deliverable: consume the bundle failureDetail (added to the dashboard endpoints in provider-platform) and show the operator WHY a bundle failed on-chain. - api.ts: BundleDetail + RecentBundleSummary now carry failureDetail; the fetch/parse reads it. - errors.ts: map SOROBAN_*/PROVIDER_*/ONCHAIN_* codes to descriptive operator copy (unknown code -> failureDetail message -> generic); adds failureReason() and the pure bundleStageTitle() row helper. - provider.ts: FAILED bundle rows show the mapped on-chain reason (inline red sub-line + tooltip), sourced from the structured failureDetail — NOT the raw WS reason string. - Tests: SOROBAN_* mapping, unknown-code fallback, and the row title.
14e96b1 to
629f549
Compare
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.
ClickUp 86cahd1d4 — follow-up to the error-bubbling line (86c8t0zux). provider-platform now returns
StructuredError { code, source?, message, details? }on non-2xx (its PlatformError wire shape{code,status,message,details}); this makes provider-console read the code and map it to operator copy, dropping string-matching / bare status / silent swallow.Error-site inventory (converted)
src/lib/api.ts— every dashboard/auth/bundle error response: auth challenge+verify,registerPp,listPps,deletePp,discoverCouncil,joinCouncil,getCouncilMembership,checkMembershipStatus, treasury/metrics/entities/bundle-detail/list. Each nowthrow await platformError(res, context); the 401 path throws a codedConsoleError(HTTP_AUTH_003).checkMembershipStatussurfaces the error instead of silently returningPENDING.src/components/page.ts+src/views/home.ts— background membership checks now log the failure for the operator instead ofcatch {}/.catch(() => {}).err.message, which is now the mapped copy, so no per-view changes were needed.Wallet not connected,Not authenticated) left as-is (client-side preconditions, not backend errors).stellar.ts/horizon.tsare Horizon, not provider-platform — they already read Horizon's structuredresult_codes; left untouched (different contract).Change
src/lib/errors.ts(new):StructuredErrortype +ConsoleError+operatorMessage(code → copy; unknown code → safe body message → generic) +platformError(res, context). Mirrors moonlight-payfriendlyError, adapted to operator copy. moonlight-sdk v0.11.1 exports noStructuredErrortype / code enum (only the contract catalog +decodeContractError), so the type + map are console-local.Codes mapped
SEP-53 challenge verify
AUTH_VR_002/003/004/005/014/015/016/017/018,ACH_VR_001,ACH_ST_003/004/007; JWTHTTP_AUTH_001-004; payloadHTTP_PRO_001; bundle-readBND_008/009/011/013/014/015/016. Unknown code → bodymessage(if a safe sentence) → generic last resort. (SOROBAN_*arrive only via a bundle'sfailureDetail, which provider-console'sBundleDetailtype doesn't include / render — out of scope here; noted.)Tests
Mapper unit tests
src/lib/errors_test.ts— 6/0 (known code → copy, unknown → safe message, unsafe → fallback/generic,isSafeSentence,platformErrormaps + carries code, non-JSON → context). Fulldeno test src/: 13/0.deno task check/lint/fmt --check/build: green.Note:
src/app-styles.csscarries adeno fmtreformat (pre-existing drift) to keep thedeno fmt --check src/gate green — unrelated to the error handling.