Improve Soroban and network error messaging with human-readable diagnostics - #72
Merged
Merged
Conversation
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.
Description
This PR improves the way Soroban RPC and network failures are surfaced to users by replacing raw, opaque error strings with clearer, more actionable messages.
Summary
Soroban RPC responses often return terse codes such as
tx_bad_seq,contract_error, andauth_revoked, which are difficult for end users and even many integrators to interpret. The current implementation was exposing these raw values directly, leading to confusing toast notifications and unnecessary support escalations for issues that are often straightforward to resolve.This change introduces a structured error-resolution layer in errors.ts that translates known Soroban and network error patterns into user-friendly messages, classifies the severity of errors, and prepares them for display in the UI.
What changed
SOROBAN_ERROR_CODESdictionary with more than 15 known Soroban error substring mappings.NETWORK_ERROR_KEYWORDSfor common JavaScript and browser-level network failures, including fetch, websocket, timeout, DNS, abort, and connection reset scenarios.resolveSorobanError(rawError: string)to:classifyError(error: unknown)to assign:low,medium, orhightrueorfalseformatErrorForDisplay(error: unknown)to prepend severity tags for UI display.Why this matters
This improves the user experience in a few important ways:
Verification
Verified locally with:
npx vitest --run tests/unit/errors.test.tsResult:
Closes #9