docs: add error handling and UX guidelines for OnchainKit transactions#2648
Open
schoolkamsergj wants to merge 2 commits into
Open
docs: add error handling and UX guidelines for OnchainKit transactions#2648schoolkamsergj wants to merge 2 commits into
schoolkamsergj wants to merge 2 commits into
Conversation
🟡 Heimdall Review Status
|
|
@schoolkamsergj is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Adds a new
error-handling.mdguide to address the documentation gap raised in #2570.OnchainKit exposes several user-facing failure modes but there was no centralized guidance on how errors are surfaced or how apps should translate them into clear, user-friendly messages.
What's added
packages/onchainkit/src/transaction/docs/error-handling.mdBased on actual source types:
TransactionError—{ code: string, error: string, message: string }, re-exported from@coinbase/onchainkit/transactionLifecycleStatus— union type withstatusName: 'error'carryingTransactionErrorasstatusDataisUserRejectedRequestError()— existing util that checkserr.cause.name === 'UserRejectedRequestError'SEND_CALLS_NOT_SUPPORTED_ERRORconstant fromconstants.tsFive error categories covered:
useAccount(), disable UI before reaching OnchainKituseChainId(), offerswitchChain()button;<Transaction chainId={base.id}>guards this automaticallyTransactionError.messageas"User rejected"string (no numeric code onTransactionError)TransactionError.messageas"insufficient funds"string, link to<FundButton>TransactionError.message, exponential backoff recommendedPatterns included:
classifyTransactionError()— mapsTransactionErrorfields to anErrorCategoryenum via string matching on.messageand.errorUSER_MESSAGESlookup table for app-wide consistent copy<Transaction onError>and<Transaction onStatus>propsWhy this matters
Without this guide, every team building on OnchainKit independently implements error parsing — resulting in inconsistent UX across the Base ecosystem. This centralizes the recommended patterns based on the actual library types.
Fixes #2570