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
- Build an error code dictionary (
SOROBAN_ERROR_CODES) mapping known Soroban error substrings to human-readable messages (minimum 15 entries).
- 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
- Implement
classifyError(error: unknown): { message, severity: "low"|"medium"|"high", actionable: boolean }.
- Implement
formatErrorForDisplay(error: unknown): string that prepends severity level.
- 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
Scope
File:
src/utils/errors.tsProblem
Soroban RPC returns terse error codes like
tx_bad_seq,contract_error,auth_revokedthat 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
SOROBAN_ERROR_CODES) mapping known Soroban error substrings to human-readable messages (minimum 15 entries).resolveSorobanError(rawError: string): stringthat:classifyError(error: unknown): { message, severity: "low"|"medium"|"high", actionable: boolean }.formatErrorForDisplay(error: unknown): stringthat prepends severity level.Resolution Strategy
{[keyword]: message}— checkerror.includes(keyword).Tags
utils, errors, soroban, ux