solana_sdk/transaction/
error.rs1use {
2 crate::{
3 instruction::InstructionError,
4 message::{AddressLoaderError, SanitizeMessageError},
5 sanitize::SanitizeError,
6 },
7 serde::Serialize,
8 thiserror::Error,
9};
10
11#[derive(
13 Error, Serialize, Deserialize, Debug, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor,
14)]
15pub enum TransactionError {
16 #[error("Account in use")]
19 AccountInUse,
20
21 #[error("Account loaded twice")]
24 AccountLoadedTwice,
25
26 #[error("Attempt to debit an account but found no record of a prior credit.")]
28 AccountNotFound,
29
30 #[error("Attempt to load a program that does not exist")]
32 ProgramAccountNotFound,
33
34 #[error("Insufficient funds for fee")]
36 InsufficientFundsForFee,
37
38 #[error("This account may not be used to pay transaction fees")]
40 InvalidAccountForFee,
41
42 #[error("This transaction has already been processed")]
46 AlreadyProcessed,
47
48 #[error("Blockhash not found")]
51 BlockhashNotFound,
52
53 #[error("Error processing Instruction {0}: {1}")]
56 InstructionError(u8, InstructionError),
57
58 #[error("Loader call chain is too deep")]
60 CallChainTooDeep,
61
62 #[error("Transaction requires a fee but has no signature present")]
64 MissingSignatureForFee,
65
66 #[error("Transaction contains an invalid account reference")]
68 InvalidAccountIndex,
69
70 #[error("Transaction did not pass signature verification")]
72 SignatureFailure,
73
74 #[error("This program may not be used for executing instructions")]
76 InvalidProgramForExecution,
77
78 #[error("Transaction failed to sanitize accounts offsets correctly")]
82 SanitizeFailure,
83
84 #[error("Transactions are currently disabled due to cluster maintenance")]
85 ClusterMaintenance,
86
87 #[error("Transaction processing left an account with an outstanding borrowed reference")]
89 AccountBorrowOutstanding,
90
91 #[error("Transaction would exceed max Block Cost Limit")]
93 WouldExceedMaxBlockCostLimit,
94
95 #[error("Transaction version is unsupported")]
97 UnsupportedVersion,
98
99 #[error("Transaction loads a writable account that cannot be written")]
101 InvalidWritableAccount,
102
103 #[error("Transaction would exceed max account limit within the block")]
105 WouldExceedMaxAccountCostLimit,
106
107 #[error("Transaction would exceed account data limit within the block")]
109 WouldExceedAccountDataBlockLimit,
110
111 #[error("Transaction locked too many accounts")]
113 TooManyAccountLocks,
114
115 #[error("Transaction loads an address table account that doesn't exist")]
117 AddressLookupTableNotFound,
118
119 #[error("Transaction loads an address table account with an invalid owner")]
121 InvalidAddressLookupTableOwner,
122
123 #[error("Transaction loads an address table account with invalid data")]
125 InvalidAddressLookupTableData,
126
127 #[error("Transaction address table lookup uses an invalid index")]
129 InvalidAddressLookupTableIndex,
130
131 #[error("Transaction leaves an account with a lower balance than rent-exempt minimum")]
133 InvalidRentPayingAccount,
134
135 #[error("Transaction would exceed max Vote Cost Limit")]
137 WouldExceedMaxVoteCostLimit,
138
139 #[error("Transaction would exceed total account data limit")]
141 WouldExceedAccountDataTotalLimit,
142
143 #[error("Transaction contains a duplicate instruction ({0}) that is not allowed")]
145 DuplicateInstruction(u8),
146
147 #[error(
149 "Transaction results in an account ({account_index}) without insufficient funds for rent"
150 )]
151 InsufficientFundsForRent { account_index: u8 },
152}
153
154impl From<SanitizeError> for TransactionError {
155 fn from(_: SanitizeError) -> Self {
156 Self::SanitizeFailure
157 }
158}
159
160impl From<SanitizeMessageError> for TransactionError {
161 fn from(err: SanitizeMessageError) -> Self {
162 match err {
163 SanitizeMessageError::AddressLoaderError(err) => Self::from(err),
164 _ => Self::SanitizeFailure,
165 }
166 }
167}
168
169impl From<AddressLoaderError> for TransactionError {
170 fn from(err: AddressLoaderError) -> Self {
171 match err {
172 AddressLoaderError::Disabled => Self::UnsupportedVersion,
173 AddressLoaderError::SlotHashesSysvarNotFound => Self::AccountNotFound,
174 AddressLoaderError::LookupTableAccountNotFound => Self::AddressLookupTableNotFound,
175 AddressLoaderError::InvalidAccountOwner => Self::InvalidAddressLookupTableOwner,
176 AddressLoaderError::InvalidAccountData => Self::InvalidAddressLookupTableData,
177 AddressLoaderError::InvalidLookupIndex => Self::InvalidAddressLookupTableIndex,
178 }
179 }
180}