spl_tlv_account_resolution/
error.rs1use {
4 solana_decode_error::DecodeError,
5 solana_msg::msg,
6 solana_program_error::{PrintProgramError, ProgramError},
7};
8
9#[repr(u32)]
11#[derive(Clone, Debug, Eq, thiserror::Error, num_derive::FromPrimitive, PartialEq)]
12pub enum AccountResolutionError {
13 #[error("Incorrect account provided")]
15 IncorrectAccount = 2_724_315_840,
16 #[error("Not enough accounts provided")]
18 NotEnoughAccounts,
19 #[error("No value initialized in TLV data")]
21 TlvUninitialized,
22 #[error("Some value initialized in TLV data")]
24 TlvInitialized,
25 #[error("Too many pubkeys provided")]
27 TooManyPubkeys,
28 #[error("Failed to parse `Pubkey` from bytes")]
30 InvalidPubkey,
31 #[error(
34 "Attempted to deserialize an `AccountMeta` but the underlying type has PDA configurations rather \
35 than a fixed address"
36 )]
37 AccountTypeNotAccountMeta,
38 #[error("Provided list of seed configurations too large for a validation account")]
40 SeedConfigsTooLarge,
41 #[error("Not enough bytes available to pack seed configuration")]
43 NotEnoughBytesForSeed,
44 #[error("The provided bytes are not valid for a seed configuration")]
46 InvalidBytesForSeed,
47 #[error("Tried to pack an invalid seed configuration")]
49 InvalidSeedConfig,
50 #[error("Instruction data too small for seed configuration")]
52 InstructionDataTooSmall,
53 #[error("Could not find account at specified index")]
55 AccountNotFound,
56 #[error("Error in checked math operation")]
58 CalculationFailure,
59 #[error("Could not find account data at specified index")]
61 AccountDataNotFound,
62 #[error("Account data too small for requested seed configuration")]
64 AccountDataTooSmall,
65 #[error("Failed to fetch account")]
67 AccountFetchFailed,
68 #[error("Not enough bytes available to pack pubkey data configuration")]
70 NotEnoughBytesForPubkeyData,
71 #[error("The provided bytes are not valid for a pubkey data configuration")]
73 InvalidBytesForPubkeyData,
74 #[error("Tried to pack an invalid pubkey data configuration")]
76 InvalidPubkeyDataConfig,
77}
78
79impl From<AccountResolutionError> for ProgramError {
80 fn from(e: AccountResolutionError) -> Self {
81 ProgramError::Custom(e as u32)
82 }
83}
84
85impl<T> DecodeError<T> for AccountResolutionError {
86 fn type_of() -> &'static str {
87 "AccountResolutionError"
88 }
89}
90
91impl PrintProgramError for AccountResolutionError {
92 fn print<E>(&self)
93 where
94 E: 'static
95 + std::error::Error
96 + DecodeError<E>
97 + PrintProgramError
98 + num_traits::FromPrimitive,
99 {
100 match self {
101 AccountResolutionError::IncorrectAccount => {
102 msg!("Incorrect account provided")
103 }
104 AccountResolutionError::NotEnoughAccounts => {
105 msg!("Not enough accounts provided")
106 }
107 AccountResolutionError::TlvUninitialized => {
108 msg!("No value initialized in TLV data")
109 }
110 AccountResolutionError::TlvInitialized => {
111 msg!("Some value initialized in TLV data")
112 }
113 AccountResolutionError::TooManyPubkeys => {
114 msg!("Too many pubkeys provided")
115 }
116 AccountResolutionError::InvalidPubkey => {
117 msg!("Failed to parse `Pubkey` from bytes")
118 }
119 AccountResolutionError::AccountTypeNotAccountMeta => {
120 msg!(
121 "Attempted to deserialize an `AccountMeta` but the underlying type has PDA configs rather than a fixed address",
122 )
123 }
124 AccountResolutionError::SeedConfigsTooLarge => {
125 msg!("Provided list of seed configurations too large for a validation account",)
126 }
127 AccountResolutionError::NotEnoughBytesForSeed => {
128 msg!("Not enough bytes available to pack seed configuration",)
129 }
130 AccountResolutionError::InvalidBytesForSeed => {
131 msg!("The provided bytes are not valid for a seed configuration",)
132 }
133 AccountResolutionError::InvalidSeedConfig => {
134 msg!("Tried to pack an invalid seed configuration",)
135 }
136 AccountResolutionError::InstructionDataTooSmall => {
137 msg!("Instruction data too small for seed configuration",)
138 }
139 AccountResolutionError::AccountNotFound => {
140 msg!("Could not find account at specified index",)
141 }
142 AccountResolutionError::CalculationFailure => {
143 msg!("Error in checked math operation")
144 }
145 AccountResolutionError::AccountDataNotFound => {
146 msg!("Could not find account data at specified index",)
147 }
148 AccountResolutionError::AccountDataTooSmall => {
149 msg!("Account data too small for requested seed configuration",)
150 }
151 AccountResolutionError::AccountFetchFailed => {
152 msg!("Failed to fetch account")
153 }
154 AccountResolutionError::NotEnoughBytesForPubkeyData => {
155 msg!("Not enough bytes available to pack pubkey data configuration",)
156 }
157 AccountResolutionError::InvalidBytesForPubkeyData => {
158 msg!("The provided bytes are not valid for a pubkey data configuration",)
159 }
160 AccountResolutionError::InvalidPubkeyDataConfig => {
161 msg!("Tried to pack an invalid pubkey data configuration",)
162 }
163 }
164 }
165}