Skip to content

feat(errors): implement human-readable Stellar and Soroban error decoder (#180) - #205

Merged
JamesEjembi merged 2 commits into
VeriNode-Labs:mainfrom
Simultech369:feat/stellar-error-decoder
Aug 22, 2026
Merged

feat(errors): implement human-readable Stellar and Soroban error decoder (#180)#205
JamesEjembi merged 2 commits into
VeriNode-Labs:mainfrom
Simultech369:feat/stellar-error-decoder

Conversation

@Simultech369

Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request resolves #180 by implementing a human-readable dictionary and decoding pipeline mapping cryptic Stellar Horizon transaction errors (tx_failed, op_underfunded, tx_bad_seq, op_no_trust) and Soroban RPC HostError / ContractError codes into actionable diagnostics with recommended troubleshooting steps.

🎯 Key Implementations

  1. src/utils/errorDecoder.ts — Error Catalog & High-Performance Decoder

    • ERROR_CATALOG: Strongly-typed dictionary mapping 60+ low-level transaction codes, operation codes, Soroban host errors, contract revert codes, and wallet/network errors into human descriptions and troubleshooting steps.
    • extractErrorMessage: Normalizes arbitrary error inputs (strings, Error instances, Axios/Fetch errors, JSON-RPC responses, Horizon result_codes).
    • decodeTransactionError: High-performance regex and code matching executing in under 0.01ms per lookup (< 0.1ms target).
    • Dynamic Interpolation: Automatically extracts and interpolates parameters (e.g. ContractError(#)).
    • Graceful Fallbacks: Comprehensive handling of edge cases (null, undefined, empty string, numbers, unknown errors).
  2. src/components/shared/ErrorDisplay.tsx — Accessible Error Display Component

    • Severity badges (Critical Error, Warning, Notice) with distinct theme styling.
    • Numbered step-by-step troubleshooting checklist.
    • External documentation links (docsUrl) when available.
    • "Copy Error Details" button with instant clipboard confirmation.
    • Expandable technical details accordion displaying raw codes and timestamps.
    • Optional onDismiss and onRetry callbacks.
  3. API Integration (src/lib/api/staking.ts)

    • Wrapped transaction submission failures with decodeTransactionError.
  4. Comprehensive Unit & Component Tests (src/__tests__/errorDecoder.test.ts, src/__tests__/ErrorDisplay.test.tsx)

    • 29/29 dedicated tests verifying catalog coverage, error categorization, regex extractions, edge cases, performance benchmarks, and React component interactivity.

🧪 Verification & Testing

  • npm run test:unit:

@JamesEjembi
JamesEjembi merged commit e738e90 into VeriNode-Labs:main Aug 22, 2026
0 of 5 checks passed
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.

Human-Readable Dictionary Mapping Cryptic Stellar Node Exceptions

2 participants