Custom errors are defined in Anchor programs to provide meaningful error messages when instructions fail. This endpoint returns all error codes and their descriptions from the program’s IDL.
{ "projectId": "proj_abc123", "programName": "token_swap", "errors": [ { "code": 6000, "name": "InsufficientLiquidity", "msg": "The pool does not have enough liquidity for this swap" }, { "code": 6001, "name": "SlippageExceeded", "msg": "The actual swap amount is below the minimum specified (slippage protection)" }, { "code": 6002, "name": "PoolPaused", "msg": "This pool is currently paused and cannot process swaps" }, { "code": 6003, "name": "InvalidFee", "msg": "Fee must be between 0 and 10000 basis points (0-100%)" }, { "code": 6004, "name": "UnauthorizedAdmin", "msg": "Only the pool authority can perform this action" }, { "code": 6005, "name": "InvalidTokenMint", "msg": "Token mint does not match pool configuration" }, { "code": 6006, "name": "ZeroAmount", "msg": "Amount must be greater than zero" }, { "code": 6007, "name": "MathOverflow", "msg": "Arithmetic overflow occurred during calculation" }, { "code": 6008, "name": "MinLiquidityNotMet", "msg": "Initial liquidity is below the minimum required amount" }, { "code": 6009, "name": "ImbalancedDeposit", "msg": "Token deposit ratio does not match current pool reserves" }, { "code": 6010, "name": "WithdrawalTooLarge", "msg": "Cannot withdraw more liquidity than you have deposited" }, { "code": 6011, "name": "PoolAlreadyInitialized", "msg": "This pool has already been initialized" }, { "code": 6012, "name": "InvalidOracle", "msg": "Oracle price feed is invalid or stale" } ]}
Anchor custom errors start at code 6000 and increment sequentially. When a transaction fails with a custom error, you’ll see the error code in the transaction logs.