mpl_agent_tools/generated/errors/
mpl_agent_tools.rs1use num_derive::FromPrimitive;
9use solana_program_error::{ProgramError, ToStr};
10use thiserror::Error;
11
12#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
13pub enum MplAgentToolsError {
14 #[error("Invalid System Program")]
16 InvalidSystemProgram,
17 #[error("Invalid instruction data")]
19 InvalidInstructionData,
20 #[error("Invalid account data")]
22 InvalidAccountData,
23 #[error("Invalid MPL Core Program")]
25 InvalidMplCoreProgram,
26 #[error("Invalid Core Asset")]
28 InvalidCoreAsset,
29 #[error("Executive Profile must be uninitialized")]
31 ExecutiveProfileMustBeUninitialized,
32 #[error("Invalid Execution Delegate Record Derivation")]
34 InvalidExecutionDelegateRecordDerivation,
35 #[error("Execution Delegate Record must be uninitialized")]
37 ExecutionDelegateRecordMustBeUninitialized,
38 #[error("Invalid Agent Identity")]
40 InvalidAgentIdentity,
41 #[error("Agent Identity not registered")]
43 AgentIdentityNotRegistered,
44 #[error("Asset owner must be the one to delegate execution")]
46 AssetOwnerMustBeTheOneToDelegateExecution,
47 #[error("Invalid Executive Profile Derivation")]
49 InvalidExecutiveProfileDerivation,
50 #[error("Execution Delegate Record must be initialized")]
52 ExecutionDelegateRecordMustBeInitialized,
53 #[error("Authority must be asset owner or executive to revoke")]
55 UnauthorizedRevoke,
56 #[error("Executive Profile must be initialized")]
58 ExecutiveProfileMustBeInitialized,
59}
60
61impl From<MplAgentToolsError> for ProgramError {
62 fn from(e: MplAgentToolsError) -> Self {
63 ProgramError::Custom(e as u32)
64 }
65}
66
67impl TryFrom<u32> for MplAgentToolsError {
68 type Error = ProgramError;
69 fn try_from(error: u32) -> Result<Self, Self::Error> {
70 match error {
71 0 => Ok(MplAgentToolsError::InvalidSystemProgram),
72 1 => Ok(MplAgentToolsError::InvalidInstructionData),
73 2 => Ok(MplAgentToolsError::InvalidAccountData),
74 3 => Ok(MplAgentToolsError::InvalidMplCoreProgram),
75 4 => Ok(MplAgentToolsError::InvalidCoreAsset),
76 5 => Ok(MplAgentToolsError::ExecutiveProfileMustBeUninitialized),
77 6 => Ok(MplAgentToolsError::InvalidExecutionDelegateRecordDerivation),
78 7 => Ok(MplAgentToolsError::ExecutionDelegateRecordMustBeUninitialized),
79 8 => Ok(MplAgentToolsError::InvalidAgentIdentity),
80 9 => Ok(MplAgentToolsError::AgentIdentityNotRegistered),
81 10 => Ok(MplAgentToolsError::AssetOwnerMustBeTheOneToDelegateExecution),
82 11 => Ok(MplAgentToolsError::InvalidExecutiveProfileDerivation),
83 12 => Ok(MplAgentToolsError::ExecutionDelegateRecordMustBeInitialized),
84 13 => Ok(MplAgentToolsError::UnauthorizedRevoke),
85 14 => Ok(MplAgentToolsError::ExecutiveProfileMustBeInitialized),
86 _ => Err(ProgramError::InvalidArgument),
87 }
88 }
89}
90
91impl ToStr for MplAgentToolsError {
92 fn to_str(&self) -> &'static str {
93 match self {
94 MplAgentToolsError::InvalidSystemProgram => "Invalid System Program",
95 MplAgentToolsError::InvalidInstructionData => "Invalid instruction data",
96 MplAgentToolsError::InvalidAccountData => "Invalid account data",
97 MplAgentToolsError::InvalidMplCoreProgram => "Invalid MPL Core Program",
98 MplAgentToolsError::InvalidCoreAsset => "Invalid Core Asset",
99 MplAgentToolsError::ExecutiveProfileMustBeUninitialized => {
100 "Executive Profile must be uninitialized"
101 }
102 MplAgentToolsError::InvalidExecutionDelegateRecordDerivation => {
103 "Invalid Execution Delegate Record Derivation"
104 }
105 MplAgentToolsError::ExecutionDelegateRecordMustBeUninitialized => {
106 "Execution Delegate Record must be uninitialized"
107 }
108 MplAgentToolsError::InvalidAgentIdentity => "Invalid Agent Identity",
109 MplAgentToolsError::AgentIdentityNotRegistered => "Agent Identity not registered",
110 MplAgentToolsError::AssetOwnerMustBeTheOneToDelegateExecution => {
111 "Asset owner must be the one to delegate execution"
112 }
113 MplAgentToolsError::InvalidExecutiveProfileDerivation => {
114 "Invalid Executive Profile Derivation"
115 }
116 MplAgentToolsError::ExecutionDelegateRecordMustBeInitialized => {
117 "Execution Delegate Record must be initialized"
118 }
119 MplAgentToolsError::UnauthorizedRevoke => {
120 "Authority must be asset owner or executive to revoke"
121 }
122 MplAgentToolsError::ExecutiveProfileMustBeInitialized => {
123 "Executive Profile must be initialized"
124 }
125 }
126 }
127}