Skip to main content

parseCypherError

Use parseCypherError to extract a structured error from any thrown value. It handles all the ways Anchor can surface program errors - direct AnchorError instances, log lines, and raw transaction simulation failures.
TypeScript

Return type

TypeScript
Returns null if the thrown value is not a Cypher program error.

Error codes

All Cypher errors start at Anchor’s 6000 offset.

ReadonlyWalletError

Thrown by readonlyWallet when a write path tries to sign. Means a mutation hook (usePlaceBet, useClaimPayout, …) fired against a CypherClient whose wallet hasn’t finished connecting. Gate the calling UI on your wallet adapter’s ready state.
TypeScript
Detect it in a mutation handler to show a friendly “connect wallet” prompt instead of leaking the SDK detail:
TypeScript
For programmatic detection in environments where instanceof checks may not survive (multiple SDK copies, RSC boundaries, etc.), match on the stable code:
TypeScript
Available since v0.8.9.

Common patterns

Check for a specific error:
TypeScript
Handle in React:
TypeScript