Appearance
Errors
How wallet failures surface in React.
- Hook
errorstate —useAvailableWallets().error,useWalletBalances().error,useWalletTransferPlan().error,useWalletTransferQuote().error,useWalletTransfer().error,useWalletTransferMinAmount().error. - Rejected promises —
connect(),disconnect(),submit()/retry()(also copied ontouseWalletTransfer().error). useConnectWallet().errors— last message keyed by provider orwalletId.useWallet(provider).erroris the same map scoped to that provider.- Events —
useOnWalletTransferStatus(failed/requires_retry);useClientEvent('wallets:error', …).
Branch on ConnectSdkError.code. Full code list: Errors (Core).
tsx
import {
ConnectSdkError,
ConnectSdkErrorCode,
} from '@swapped/connect-sdk'
import { useWallet } from '@swapped/connect-sdk/react'
function ConnectButton({ provider }: { provider: IntegrationProvider }) {
const { connect } = useWallet(provider)
return (
<button
type="button"
onClick={() => {
void connect().catch(error => {
if (
error instanceof ConnectSdkError &&
(error.code === ConnectSdkErrorCode.WALLET_CONNECT_REJECTED ||
error.code === ConnectSdkErrorCode.WALLET_PAIRING_CANCELLED)
) {
return
}
// other codes
})
}}
>
Connect
</button>
)
}WALLET_CONNECT_REJECTED / WALLET_TRANSACTION_REJECTED are user cancels. WALLET_PAIRING_CANCELLED is cancelPairing (or a force: true connect) aborting an in-flight pairing — the demo ignores that one when tearing down the WalletConnect tab.
REACT_WALLETS_PROVIDER_REQUIRED is thrown when a provider-bound hook is used outside WalletsProvider.
useDualAmountInput().error is an AmountValidationError ({ code, message, metadata }), not a ConnectSdkError. code includes below_min.
useDualAmountInput uses the min from useWalletTransferMinAmount.