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