mpl_token_auth_rules/
error.rs1use num_derive::FromPrimitive;
3use solana_program::{
4 decode_error::DecodeError,
5 msg,
6 program_error::{PrintProgramError, ProgramError},
7};
8use thiserror::Error;
9
10#[derive(Error, Clone, Debug, Eq, PartialEq, FromPrimitive)]
11pub enum RuleSetError {
13 #[error("Numerical Overflow")]
15 NumericalOverflow,
16
17 #[error("Data type mismatch")]
19 DataTypeMismatch,
20
21 #[error("Data slice unexpected index error")]
23 DataSliceUnexpectedIndexError,
24
25 #[error("Incorrect account owner")]
27 IncorrectOwner,
28
29 #[error("Could not index into PayloadVec")]
31 PayloadVecIndexError,
32
33 #[error("Derived key invalid")]
35 DerivedKeyInvalid,
36
37 #[error("Payer is not a signer")]
39 PayerIsNotSigner,
40
41 #[error("Not implemented")]
43 NotImplemented,
44
45 #[error("Borsh serialization error")]
47 BorshSerializationError,
48
49 #[error("Borsh deserialization error")]
51 BorshDeserializationError,
52
53 #[error("Value in Payload or RuleSet is occupied")]
55 ValueOccupied,
56
57 #[error("Account data is empty")]
59 DataIsEmpty,
60
61 #[error("MessagePack serialization error")]
63 MessagePackSerializationError,
64
65 #[error("MessagePack deserialization error")]
67 MessagePackDeserializationError,
68
69 #[error("Missing account")]
71 MissingAccount,
72
73 #[error("Missing Payload value")]
75 MissingPayloadValue,
76
77 #[error("RuleSet owner must be payer")]
79 RuleSetOwnerMismatch,
80
81 #[error("Name too long")]
83 NameTooLong,
84
85 #[error("The operation retrieved is not in the selected RuleSet")]
87 OperationNotFound,
88
89 #[error("Rule authority is not signer")]
91 RuleAuthorityIsNotSigner,
92
93 #[error("Unsupported RuleSet revision map version")]
95 UnsupportedRuleSetRevMapVersion,
96
97 #[error("Unsupported RuleSet version")]
99 UnsupportedRuleSetVersion,
100
101 #[error("Unexpected RuleSet failure")]
103 UnexpectedRuleSetFailure,
104
105 #[error("RuleSet revision not available")]
107 RuleSetRevisionNotAvailable,
108
109 #[error("Additional Signer check failed")]
111 AdditionalSignerCheckFailed,
112
113 #[error("Pubkey Match check failed")]
115 PubkeyMatchCheckFailed,
116
117 #[error("Pubkey List Match check failed")]
119 PubkeyListMatchCheckFailed,
120
121 #[error("Pubkey Tree Match check failed")]
123 PubkeyTreeMatchCheckFailed,
124
125 #[error("PDA Match check failed")]
127 PDAMatchCheckFailed,
128
129 #[error("Program Owned check failed")]
131 ProgramOwnedCheckFailed,
132
133 #[error("Program Owned List check failed")]
135 ProgramOwnedListCheckFailed,
136
137 #[error("Program Owned Tree check failed")]
139 ProgramOwnedTreeCheckFailed,
140
141 #[error("Amount checked failed")]
143 AmountCheckFailed,
144
145 #[error("Frequency check failed")]
147 FrequencyCheckFailed,
148
149 #[error("IsWallet check failed")]
151 IsWalletCheckFailed,
152
153 #[error("Program Owned Set check failed")]
155 ProgramOwnedSetCheckFailed,
156
157 #[error("Invalid compare operator")]
159 InvalidCompareOp,
160
161 #[error("Invalid constraint type value")]
163 InvalidConstraintType,
164
165 #[error("Failed to read the rule set")]
167 RuleSetReadFailed,
168
169 #[error("Duplicated operation name")]
171 DuplicatedOperationName,
172
173 #[error("Could not determine alignemnt")]
175 AlignmentError,
176}
177
178impl PrintProgramError for RuleSetError {
179 fn print<E>(&self) {
180 msg!(&self.to_string());
181 }
182}
183
184impl From<RuleSetError> for ProgramError {
185 fn from(e: RuleSetError) -> Self {
186 ProgramError::Custom(e as u32)
187 }
188}
189
190impl<T> DecodeError<T> for RuleSetError {
191 fn type_of() -> &'static str {
192 "Error Thingy"
193 }
194}