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) - Executor Profile must be uninitialized
30    #[error("Executor Profile must be uninitialized")]
31    ExecutorProfileMustBeUninitialized,
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}
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}