Skip to content

fix: consume provider-platform StructuredError, map codes to operator copy#40

Merged
AquiGorka merged 4 commits into
mainfrom
fix/structured-errors
Jul 8, 2026
Merged

fix: consume provider-platform StructuredError, map codes to operator copy#40
AquiGorka merged 4 commits into
mainfrom
fix/structured-errors

Conversation

@AquiGorka

Copy link
Copy Markdown
Contributor

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 now throw await platformError(res, context); the 401 path throws a coded ConsoleError (HTTP_AUTH_003). checkMembershipStatus surfaces the error instead of silently returning PENDING.
  • src/components/page.ts + src/views/home.ts — background membership checks now log the failure for the operator instead of catch {} / .catch(() => {}).
  • Views render err.message, which is now the mapped copy, so no per-view changes were needed.
  • Local guards (Wallet not connected, Not authenticated) left as-is (client-side preconditions, not backend errors). stellar.ts/horizon.ts are Horizon, not provider-platform — they already read Horizon's structured result_codes; left untouched (different contract).

Change

src/lib/errors.ts (new): StructuredError type + ConsoleError + operatorMessage (code → 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 / 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; JWT HTTP_AUTH_001-004; payload HTTP_PRO_001; bundle-read BND_008/009/011/013/014/015/016. Unknown code → body message (if a safe sentence) → generic last resort. (SOROBAN_* arrive only via a bundle's failureDetail, which provider-console's BundleDetail type 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, platformError maps + carries code, non-JSON → context). Full deno test src/: 13/0. deno task check / lint / fmt --check / build: green.

Note: src/app-styles.css carries a deno fmt reformat (pre-existing drift) to keep the deno fmt --check src/ gate green — unrelated to the error handling.

AquiGorka added 4 commits July 6, 2026 10:55
…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.
@AquiGorka AquiGorka force-pushed the fix/structured-errors branch from 14e96b1 to 629f549 Compare July 6, 2026 17:01
@AquiGorka AquiGorka requested a review from pselle July 6, 2026 17:26
@AquiGorka AquiGorka merged commit 5e584fc into main Jul 8, 2026
6 checks passed
@AquiGorka AquiGorka deleted the fix/structured-errors branch July 8, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant