Error Handling
Normalize SDK, RPC, and program failures through DumpsterError and DumpsterErrorCode.
SDK
Normalize errors before you branch on them
Convert a thrown error once and branch on DumpsterErrorCode instead of matching raw codes or class names.
Recommended pattern
import {
DumpsterError,
DumpsterErrorCode,
} from '@dumpster-cash/dumpster-sdk';
try {
// fetch, build, or submit
} catch (error) {
const dumpsterError = DumpsterError.fromAnchorError(error);
switch (dumpsterError.code) {
case DumpsterErrorCode.AccountNotFound:
console.log('The target account does not exist on-chain.');
break;
case DumpsterErrorCode.BondingCurveComplete:
console.log('Stop curve trading and refresh migration/pool evidence.');
break;
case DumpsterErrorCode.BondingCurveAlreadySettled:
console.log('Do not repeat settlement; refresh canonical-pool evidence.');
break;
case DumpsterErrorCode.CreatorMismatch:
console.log('Creator records disagree; request designated-authority review.');
break;
case DumpsterErrorCode.SlippageExceeded:
console.log('Refresh the preview and rebuild the transaction.');
break;
case DumpsterErrorCode.MigrationDisabled:
console.log('Migration is currently unavailable for this token.');
break;
default:
throw dumpsterError;
}
}Useful codes
| Code | What it means | Typical client response |
|---|---|---|
| AccountNotFound | A required account was missing during fetch or build. | Stop and refetch or verify the mint/pool you are using. |
| BondingCurveComplete | The token is no longer tradable on the launch curve. | Refresh migration/pool evidence before selecting an AMM venue. |
| BondingCurveNotComplete | Migration was attempted before the curve finished. | Block migration until completion. |
| BondingCurveAlreadySettled | The completed curve accounting is already cleared (program error 6023). | Do not repeat settlement or infer withdrawal from pool absence. |
| CreatorMismatch | A voluntary handover found different curve and pool recipients (program error 6024). | Stop the handover and request designated-authority reconciliation from trusted history. |
| SlippageExceeded | The preview moved outside the user's allowed bounds. | Refresh state and rebuild the transaction. |
| InsufficientBalance | The wallet does not hold enough tokens or quote to complete the action. | Refetch balances and reduce size. |
| MigrationDisabled | Migration is not currently available for the token you are targeting. | Treat migration as unavailable and re-check state later. |
| InsufficientMigrationLiquidity | Insufficient liquidity for migration (program error 6025): recorded GOR does not exceed the current fee, or the full staged base and quote do not meet the initial LP minimum. | Stop and review the current fee, recorded reserves and actual token custody; retrying unchanged funding is not recovery. |
| Disabled | The requested venue or action is currently disabled. | Disable that action path in your integration. |
| Unknown | The SDK could not confidently classify the failure. | Log the full error and inspect the transaction logs. |
Fetch/setup failures vs submitted-transaction failures
The SDK maps InsufficientMigrationLiquidityError (6025), CreatorMismatchError (6024), BondingCurveAlreadySettledError (6023) and InsufficientCurveLiquidityError (6022). Swap error NotCanonicalPool (6018) means the pool is not canonical for the configured migration program.
InsufficientMigrationLiquidity describes a migration funding rejection, not a wallet balance error or every possible migration failure. Rent, account-validation and downstream errors remain distinct.
create and set_params use the same configuration checks: invalid parameters return InvalidParams (6011), while checked-arithmetic failures return MathOverflow (6006). Inspect the failed instruction and logs before attributing the cause: create also uses InvalidParams for metadata lengths, and account, pause or authorization checks can fail first. Invalid stored settings need an authorized configuration update; changing a buyer's slippage does not correct them.
The normalizer recognizes the SDK's custom error classes; it does not decode every raw Anchor/RPC error shape. Preserve the original cause and treat unrecognized failures as Unknown. Do not turn CreatorMismatch into an automatic repair or retry with a guessed recipient.
- fetch/setup failures usually become
AccountNotFound,TransactionBuildFailed, orUnknown - submitted transactions often become
SlippageExceeded,Disabled,InsufficientBalance, orMigrationDisabled
Branch only on recognized codes. An Unknown result is not evidence that an account is absent or an operation succeeded.
Recipient configuration and selection
Recipient checks use the errors below.
| Program/code | Recipient-related cause | Response |
|---|---|---|
Curve InvalidParams (6011) | set_params or create finds a default primary or an invalid optional list. | Request an authorized configuration correction; optional empty slots remain allowed. |
Curve InvalidFeeRecipient (6008) | A trade selects a default/unlisted destination, or active migration has an invalid primary. | Use an active trade recipient; migration must use the primary. |
Swap InvalidFeeRecipients (6020) | Configuration has no active entry, duplicates, invalid order or misplaced empty slots. | Supply one to eight sorted, unique active entries with empty slots last. |
Swap Unauthorized (6000) | The trade membership check rejects the selected destination. | Check the chosen nondefault recipient against the stored list. |
Swap 6020's message is Fee recipients must include at least one non-zero address, sorted and unique, with empty slots last. Earlier account/runtime checks can fail before recipient membership, and these codes also have other uses; inspect the failed instruction and logs rather than assuming every rejection has the same cause.
Curve selection throws the plain setup error No fee recipients configured when neither an optional entry nor the primary is active. Swap selection already throws No protocol fee recipients configured for an empty active set. These are not submitted-transaction errors: the existing normalizer reports them as Unknown while retaining their message and cause. Refresh configuration and report the missing setup; do not substitute an arbitrary wallet or treat it as a slippage retry. Raw configuration reads remain available. See fee helpers.
Match a single code directly
import {
DumpsterErrorCode,
matchesDumpsterErrorCode,
} from '@dumpster-cash/dumpster-sdk';
try {
// submit transaction
} catch (error) {
if (matchesDumpsterErrorCode(error, DumpsterErrorCode.SlippageExceeded)) {
console.log('Ask the user to refresh the quote.');
}
}