Errors
SdkError variants and AURA program error codes for the Rust SDK.
Pre-alpha — not production ready
aura-sdk targets Solana devnet only. APIs may change without notice. Do not use for real funds until a stable release and audit are published.
The Rust SDK uses a single SdkError enum for all errors.
SdkError Enum
use aura_sdk::SdkError;
pub enum SdkError {
/// Solana RPC returned an error.
Rpc(solana_client::client_error::ClientError),
/// The requested account does not exist on-chain.
AccountNotFound(Pubkey),
/// Anchor account decoding failed.
AccountDecode {
account_name: &'static str,
message: String,
},
/// Converting a treasury record back into the domain model failed.
DomainDecode(String),
/// The client was asked to submit a transaction without a configured payer.
MissingDefaultPayer,
/// A caller-supplied parameter was invalid before any RPC call was made.
InvalidParameter(String),
}Handling Errors
use aura_sdk::{AuraClient, SdkError};
match client.get_treasury(&treasury_pda) {
Ok(treasury) => println!("Agent: {}", treasury.agent_id),
Err(SdkError::AccountNotFound(addr)) => {
println!("No treasury at {}", addr);
}
Err(SdkError::AccountDecode { account_name, message }) => {
eprintln!("Decode failed for {}: {}", account_name, message);
}
Err(SdkError::DomainDecode(msg)) => {
eprintln!("Domain conversion failed: {}", msg);
}
Err(SdkError::MissingDefaultPayer) => {
eprintln!("Create the client with with_payer() to use send_with_default_payer");
}
Err(SdkError::InvalidParameter(msg)) => {
eprintln!("Bad parameter: {}", msg);
}
Err(SdkError::Rpc(e)) => {
eprintln!("RPC error: {}", e);
}
}Program Error Codes
The AURA program emits Anchor error codes starting at 6000. These arrive inside SdkError::Rpc(_).
| Code | Name | Description |
|---|---|---|
| 6000 | UnauthorizedAi | Caller is not the registered AI authority |
| 6001 | UnauthorizedOwner | Caller is not the treasury owner |
| 6002 | UnauthorizedGuardian | Caller is not a registered guardian |
| 6003 | UnauthorizedExecutor | Caller is not an authorized executor |
| 6004 | PendingTransactionExists | A proposal is already pending; resolve it first |
| 6005 | NoPendingTransaction | No pending proposal to act on |
| 6006 | DWalletNotConfigured | No dWallet registered for the requested chain |
| 6007 | DWalletAlreadyRegistered | A dWallet is already registered for this chain |
| 6008 | PolicyGraphMismatch | FHE policy graph digest does not match |
| 6009 | PolicyDigestMismatch | Policy digest mismatch on verification |
| 6010 | DecryptionNotReady | Decryption result is not yet available |
| 6011 | MessageApprovalNotReady | dWallet message approval is not ready |
| 6012 | SignatureVerificationFailed | Signature verification failed |
| 6013 | InvalidDeployment | Invalid deployment configuration |
| 6014 | InvalidExternalAccountData | Invalid external account data |
| 6015 | ConfidentialGuardrailsNotConfigured | Confidential guardrails must be set up first |
| 6016 | PolicyOutputNotReady | Encrypted policy output is not ready yet |
| 6017 | ExecutionPaused | Treasury execution is currently paused |
| 6018 | PendingTransactionExpired | The pending proposal TTL has elapsed |
| 6019 | NoActiveOverride | No active guardian override to act on |
| 6020 | InvalidChain | Invalid chain value |
| 6021 | InvalidTransactionType | Invalid transaction type value |
| 6022 | InvalidCurve | Invalid dWallet curve value |
| 6023 | InvalidSignatureScheme | Invalid signature scheme value |
| 6024 | InvalidViolationCode | Invalid violation code |
| 6025 | InvalidProposalStatus | Invalid proposal status transition |
| 6026 | InvalidGuardianConfiguration | Invalid guardian configuration |
| 6027 | TimelockNotElapsed | Timelock period has not elapsed |
| 6028 | SanctionedAddress | Recipient address is on the sanctions list |
| 6029 | RecipientBlacklisted | Recipient is on the address deny list |
| 6030 | RecipientNotWhitelisted | Recipient is not on the address allow list |
| 6031 | CooldownNotElapsed | Cooldown period between large transactions has not elapsed |
| 6032 | HighRiskTransactionRequiresGuardian | High-risk transaction requires guardian co-signature |
| 6033 | InvalidStateTransition | Invalid agent state transition |
| 6034 | ParentLimitExceeded | Parent treasury limit would be exceeded |
| 6035 | AnomalyDetected | Anomaly detected in transaction pattern |
| 6036 | SessionKeyInactive | Session key has expired or was revoked |
| 6037 | SessionKeyScopeViolation | Session key scope does not permit this proposal |
| 6038 | AccountStillActive | Account cannot be closed while still active |
| 6039 | BudgetEnvelopeLimitExceeded | Budget envelope limit would be exceeded |
| 6040 | ApprovalLevelNotSatisfied | Approval ladder level has not been satisfied |
| 6041 | PendingExecutionTimelockActive | Pending execution timelock is still active |
| 6042 | ExecutionScopePaused | Execution scope is paused |
| 6043 | OperatorRoleMissing | Operator role is missing required permission |
| 6044 | OperatorRoleExpired | Operator role has expired or was revoked |
| 6045 | ExternalDependencyStale | External dependency freshness check failed |
| 6046 | InvalidPolicyPreset | Policy preset kind is invalid |
| 6047 | PolicyAttestationMismatch | Policy attestation hash or version mismatch |
| 6048 | EmptyBatch | Batch proposal cannot be empty |
| 6049 | BatchTooLarge | Batch proposal exceeds maximum item count |
| 6050 | ExposureGroupLimitExceeded | Cross-treasury exposure group limit exceeded |
| 6051 | ExposureGroupUnauthorized | Treasury is not a member of the exposure group |
Converting to anyhow
SdkError implements std::error::Error, so it works with anyhow directly:
use anyhow::{Context, Result};
use aura_sdk::AuraClient;
fn fetch_treasury(client: &AuraClient, pda: &Pubkey) -> Result<AgentTreasury> {
client
.get_treasury(pda)
.with_context(|| format!("failed to fetch treasury {}", pda))
}