Skip to main content

mpl_agent_tools/generated/errors/
mpl_agent_tools.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! [https://github.com/metaplex-foundation/kinobi]
6//!
7
8use 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    /// 0 (0x0) - Invalid System Program
15    #[error("Invalid System Program")]
16    InvalidSystemProgram,
17    /// 1 (0x1) - Invalid instruction data
18    #[error("Invalid instruction data")]
19    InvalidInstructionData,
20    /// 2 (0x2) - Invalid account data
21    #[error("Invalid account data")]
22    InvalidAccountData,
23    /// 3 (0x3) - Invalid MPL Core Program
24    #[error("Invalid MPL Core Program")]
25    InvalidMplCoreProgram,
26    /// 4 (0x4) - Invalid Core Asset
27    #[error("Invalid Core Asset")]
28    InvalidCoreAsset,
29    /// 5 (0x5) - Executive Profile must be uninitialized
30    #[error("Executive Profile must be uninitialized")]
31    ExecutiveProfileMustBeUninitialized,
32    /// 6 (0x6) - Invalid Execution Delegate Record Derivation
33    #[error("Invalid Execution Delegate Record Derivation")]
34    InvalidExecutionDelegateRecordDerivation,
35    /// 7 (0x7) - Execution Delegate Record must be uninitialized
36    #[error("Execution Delegate Record must be uninitialized")]
37    ExecutionDelegateRecordMustBeUninitialized,
38    /// 8 (0x8) - Invalid Agent Identity
39    #[error("Invalid Agent Identity")]
40    InvalidAgentIdentity,
41    /// 9 (0x9) - Agent Identity not registered
42    #[error("Agent Identity not registered")]
43    AgentIdentityNotRegistered,
44    /// 10 (0xA) - Asset owner must be the one to delegate execution
45    #[error("Asset owner must be the one to delegate execution")]
46    AssetOwnerMustBeTheOneToDelegateExecution,
47    /// 11 (0xB) - Invalid Executive Profile Derivation
48    #[error("Invalid Executive Profile Derivation")]
49    InvalidExecutiveProfileDerivation,
50    /// 12 (0xC) - Execution Delegate Record must be initialized
51    #[error("Execution Delegate Record must be initialized")]
52    ExecutionDelegateRecordMustBeInitialized,
53    /// 13 (0xD) - Authority must be asset owner or executive to revoke
54    #[error("Authority must be asset owner or executive to revoke")]
55    UnauthorizedRevoke,
56    /// 14 (0xE) - Executive Profile must be initialized
57    #[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}