spl_tlv_account_resolution/
error.rsuse {
solana_decode_error::DecodeError,
solana_msg::msg,
solana_program_error::{PrintProgramError, ProgramError},
};
#[repr(u32)]
#[derive(Clone, Debug, Eq, thiserror::Error, num_derive::FromPrimitive, PartialEq)]
pub enum AccountResolutionError {
#[error("Incorrect account provided")]
IncorrectAccount = 2_724_315_840,
#[error("Not enough accounts provided")]
NotEnoughAccounts,
#[error("No value initialized in TLV data")]
TlvUninitialized,
#[error("Some value initialized in TLV data")]
TlvInitialized,
#[error("Too many pubkeys provided")]
TooManyPubkeys,
#[error("Failed to parse `Pubkey` from bytes")]
InvalidPubkey,
#[error(
"Attempted to deserialize an `AccountMeta` but the underlying type has PDA configs rather \
than a fixed address"
)]
AccountTypeNotAccountMeta,
#[error("Provided list of seed configurations too large for a validation account")]
SeedConfigsTooLarge,
#[error("Not enough bytes available to pack seed configuration")]
NotEnoughBytesForSeed,
#[error("The provided bytes are not valid for a seed configuration")]
InvalidBytesForSeed,
#[error("Tried to pack an invalid seed configuration")]
InvalidSeedConfig,
#[error("Instruction data too small for seed configuration")]
InstructionDataTooSmall,
#[error("Could not find account at specified index")]
AccountNotFound,
#[error("Error in checked math operation")]
CalculationFailure,
#[error("Could not find account data at specified index")]
AccountDataNotFound,
#[error("Account data too small for requested seed configuration")]
AccountDataTooSmall,
#[error("Failed to fetch account")]
AccountFetchFailed,
#[error("Not enough bytes available to pack pubkey data configuration")]
NotEnoughBytesForPubkeyData,
#[error("The provided bytes are not valid for a pubkey data configuration")]
InvalidBytesForPubkeyData,
#[error("Tried to pack an invalid pubkey data configuration")]
InvalidPubkeyDataConfig,
}
impl From<AccountResolutionError> for ProgramError {
fn from(e: AccountResolutionError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for AccountResolutionError {
fn type_of() -> &'static str {
"AccountResolutionError"
}
}
impl PrintProgramError for AccountResolutionError {
fn print<E>(&self)
where
E: 'static
+ std::error::Error
+ DecodeError<E>
+ PrintProgramError
+ num_traits::FromPrimitive,
{
match self {
AccountResolutionError::IncorrectAccount => {
msg!("Incorrect account provided")
}
AccountResolutionError::NotEnoughAccounts => {
msg!("Not enough accounts provided")
}
AccountResolutionError::TlvUninitialized => {
msg!("No value initialized in TLV data")
}
AccountResolutionError::TlvInitialized => {
msg!("Some value initialized in TLV data")
}
AccountResolutionError::TooManyPubkeys => {
msg!("Too many pubkeys provided")
}
AccountResolutionError::InvalidPubkey => {
msg!("Failed to parse `Pubkey` from bytes")
}
AccountResolutionError::AccountTypeNotAccountMeta => {
msg!(
"Attempted to deserialize an `AccountMeta` but the underlying type has PDA configs rather than a fixed address",
)
}
AccountResolutionError::SeedConfigsTooLarge => {
msg!("Provided list of seed configurations too large for a validation account",)
}
AccountResolutionError::NotEnoughBytesForSeed => {
msg!("Not enough bytes available to pack seed configuration",)
}
AccountResolutionError::InvalidBytesForSeed => {
msg!("The provided bytes are not valid for a seed configuration",)
}
AccountResolutionError::InvalidSeedConfig => {
msg!("Tried to pack an invalid seed configuration",)
}
AccountResolutionError::InstructionDataTooSmall => {
msg!("Instruction data too small for seed configuration",)
}
AccountResolutionError::AccountNotFound => {
msg!("Could not find account at specified index",)
}
AccountResolutionError::CalculationFailure => {
msg!("Error in checked math operation")
}
AccountResolutionError::AccountDataNotFound => {
msg!("Could not find account data at specified index",)
}
AccountResolutionError::AccountDataTooSmall => {
msg!("Account data too small for requested seed configuration",)
}
AccountResolutionError::AccountFetchFailed => {
msg!("Failed to fetch account")
}
AccountResolutionError::NotEnoughBytesForPubkeyData => {
msg!("Not enough bytes available to pack pubkey data configuration",)
}
AccountResolutionError::InvalidBytesForPubkeyData => {
msg!("The provided bytes are not valid for a pubkey data configuration",)
}
AccountResolutionError::InvalidPubkeyDataConfig => {
msg!("Tried to pack an invalid pubkey data configuration",)
}
}
}
}