solana_nft_programs_creator_standard/
errors.rs1use solana_program::{
2 decode_error::DecodeError,
3 msg,
4 program_error::{PrintProgramError, ProgramError},
5};
6
7use {num_derive::FromPrimitive, thiserror::Error};
8
9#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
10pub enum ErrorCode {
11 #[error("Invalid account type")]
12 InvalidAccountType = 6000,
13 #[error("Data type mismatch")]
14 DataTypeMismatch,
15 #[error("Invalid mint")]
16 InvalidMint,
17 #[error("Invalid amount")]
18 InvalidAmount,
19 #[error("Invalid token account")]
20 InvalidTokenAccount,
21 #[error("Invalid authority address")]
22 InvalidAuthority,
23 #[error("Invalid mint manager")]
24 InvalidMintManager,
25 #[error("Invalid mint metadata")]
26 InvalidMintMetadata,
27 #[error("Insufficient minimum creator share")]
28 InusufficientMinimumCreatorShare,
29 #[error("Invalid holder token account")]
30 InvlaidHolderTokenAccount,
31 #[error("Invalid target token account")]
32 InvalidTargetTokenAccount,
33 #[error("Invalid token account to close")]
34 InvalidCloseTokenAccount,
35 #[error("Invalid holder token account")]
36 InvalidHolderTokenAccount,
37 #[error("Invalid ruleset")]
38 InvalidRuleset,
39 #[error("Invalid pre transfer instruction")]
40 InvalidPreTransferInstruction,
41 #[error("Invalid post transfer instruction")]
42 InvalidPostTransferInstruction,
43 #[error("Disallowed address included")]
44 AddressDisallowed,
45 #[error("Program not allowed in allowed programs to transfer")]
46 ProgramNotAllowed,
47 #[error("Unknown account found in instruction")]
48 UnknownAccount,
49 #[error("Account not found in instruction")]
50 AccountNotFound,
51 #[error("Token already in use")]
52 TokenAlreadyInUse,
53 #[error("Invalid token user")]
54 InvalidTokenUser,
55 #[error("Token currently in use")]
56 TokenCurentlyInUse,
57 #[error("Invalid ruleset authority")]
58 InvalidRulesetAuthority,
59 #[error("Invalid freeze authority")]
60 InvalidFreezeAuthority,
61 #[error("Invalid mint authority")]
62 InvalidMintAuthority,
63 #[error("Not enought remaining accounts")]
64 NotEnoughRemainingAccounts,
65}
66
67impl PrintProgramError for ErrorCode {
68 fn print<E>(&self) {
69 msg!(&self.to_string());
70 }
71}
72
73impl From<ErrorCode> for ProgramError {
74 fn from(e: ErrorCode) -> Self {
75 ProgramError::Custom(e as u32)
76 }
77}
78
79impl<T> DecodeError<T> for ErrorCode {
80 fn type_of() -> &'static str {
81 "Creator Standard Error"
82 }
83}