spl_token_metadata_interface/
error.rs1use solana_program_error::{ProgramError, ToStr};
4
5#[repr(u32)]
7#[derive(
8 Clone,
9 Debug,
10 Eq,
11 thiserror::Error,
12 num_derive::FromPrimitive,
13 num_enum::TryFromPrimitive,
14 PartialEq,
15)]
16pub enum TokenMetadataError {
17 #[error("Incorrect account provided")]
19 IncorrectAccount = 901_952_957,
20 #[error("Mint has no mint authority")]
22 MintHasNoMintAuthority,
23 #[error("Incorrect mint authority has signed the instruction")]
25 IncorrectMintAuthority,
26 #[error("Incorrect metadata update authority has signed the instruction")]
28 IncorrectUpdateAuthority,
29 #[error("Token metadata has no update authority")]
31 ImmutableMetadata,
32 #[error("Key not found in metadata account")]
34 KeyNotFound,
35}
36
37impl From<TokenMetadataError> for ProgramError {
38 fn from(e: TokenMetadataError) -> Self {
39 ProgramError::Custom(e as u32)
40 }
41}
42
43impl ToStr for TokenMetadataError {
44 fn to_str(&self) -> &'static str {
45 match self {
46 TokenMetadataError::IncorrectAccount => "Incorrect account provided",
47 TokenMetadataError::MintHasNoMintAuthority => "Mint has no mint authority",
48 TokenMetadataError::IncorrectMintAuthority => {
49 "Incorrect mint authority has signed the instruction"
50 }
51 TokenMetadataError::IncorrectUpdateAuthority => {
52 "Incorrect metadata update authority has signed the instruction"
53 }
54 TokenMetadataError::ImmutableMetadata => "Token metadata has no update authority",
55 TokenMetadataError::KeyNotFound => "Key not found in metadata account",
56 }
57 }
58}