Skip to content

Issue 10: Human-Readable Dictionary Layer Mapping Cryptic Soroban Error Codes #9

Description

@elizabetheonoja-art

Scope

File: src/utils/errors.ts

Problem

Soroban RPC returns terse error codes like tx_bad_seq, contract_error, auth_revoked that are meaningless to end users and even to most integrators. The current error handling simply throws the raw error string, resulting in confusing toast notifications and support tickets for trivially resolvable issues.

Requirements

  1. Build an error code dictionary (SOROBAN_ERROR_CODES) mapping known Soroban error substrings to human-readable messages (minimum 15 entries).
  2. Implement resolveSorobanError(rawError: string): string that:
    • Normalizes the error to lowercase
    • Checks the dictionary for substring matches
    • Falls back to network error keywords
    • Truncates and wraps unknown errors with a generic message
  3. Implement classifyError(error: unknown): { message, severity: "low"|"medium"|"high", actionable: boolean }.
  4. Implement formatErrorForDisplay(error: unknown): string that prepends severity level.
  5. Add network error keyword mapping for common JS fetch/WebSocket errors.

Resolution Strategy

  • Dictionary approach: {[keyword]: message} — check error.includes(keyword).
  • Classify: auth errors → high/actionable, balance/fee errors → medium/actionable, timeout → medium/actionable, everything else → low/not actionable.
  • Pure functions with full test coverage.

Tags

utils, errors, soroban, ux

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions