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("Executor Profile must be uninitialized")]
31 ExecutorProfileMustBeUninitialized,
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}
45
46impl From<MplAgentToolsError> for ProgramError {
47 fn from(e: MplAgentToolsError) -> Self {
48 ProgramError::Custom(e as u32)
49 }
50}
51
52impl TryFrom<u32> for MplAgentToolsError {
53 type Error = ProgramError;
54 fn try_from(error: u32) -> Result<Self, Self::Error> {
55 match error {
56 0 => Ok(MplAgentToolsError::InvalidSystemProgram),
57 1 => Ok(MplAgentToolsError::InvalidInstructionData),
58 2 => Ok(MplAgentToolsError::InvalidAccountData),
59 3 => Ok(MplAgentToolsError::InvalidMplCoreProgram),
60 4 => Ok(MplAgentToolsError::InvalidCoreAsset),
61 5 => Ok(MplAgentToolsError::ExecutorProfileMustBeUninitialized),
62 6 => Ok(MplAgentToolsError::InvalidExecutionDelegateRecordDerivation),
63 7 => Ok(MplAgentToolsError::ExecutionDelegateRecordMustBeUninitialized),
64 8 => Ok(MplAgentToolsError::InvalidAgentIdentity),
65 9 => Ok(MplAgentToolsError::AgentIdentityNotRegistered),
66 _ => Err(ProgramError::InvalidArgument),
67 }
68 }
69}
70
71impl ToStr for MplAgentToolsError {
72 fn to_str(&self) -> &'static str {
73 match self {
74 MplAgentToolsError::InvalidSystemProgram => "Invalid System Program",
75 MplAgentToolsError::InvalidInstructionData => "Invalid instruction data",
76 MplAgentToolsError::InvalidAccountData => "Invalid account data",
77 MplAgentToolsError::InvalidMplCoreProgram => "Invalid MPL Core Program",
78 MplAgentToolsError::InvalidCoreAsset => "Invalid Core Asset",
79 MplAgentToolsError::ExecutorProfileMustBeUninitialized => {
80 "Executor Profile must be uninitialized"
81 }
82 MplAgentToolsError::InvalidExecutionDelegateRecordDerivation => {
83 "Invalid Execution Delegate Record Derivation"
84 }
85 MplAgentToolsError::ExecutionDelegateRecordMustBeUninitialized => {
86 "Execution Delegate Record must be uninitialized"
87 }
88 MplAgentToolsError::InvalidAgentIdentity => "Invalid Agent Identity",
89 MplAgentToolsError::AgentIdentityNotRegistered => "Agent Identity not registered",
90 }
91 }
92}