use solana_program_error::{ProgramError, ToStr};
#[repr(u32)]
#[derive(
Clone,
Debug,
Eq,
thiserror::Error,
num_derive::FromPrimitive,
num_enum::TryFromPrimitive,
PartialEq,
)]
pub enum TokenGroupError {
#[error("Size is greater than proposed max size")]
SizeExceedsNewMaxSize = 3_406_457_176,
#[error("Size is greater than max size")]
SizeExceedsMaxSize,
#[error("Group is immutable")]
ImmutableGroup,
#[error("Incorrect mint authority has signed the instruction")]
IncorrectMintAuthority,
#[error("Incorrect update authority has signed the instruction")]
IncorrectUpdateAuthority,
#[error("Member account should not be the same as the group account")]
MemberAccountIsGroupAccount,
}
impl From<TokenGroupError> for ProgramError {
fn from(e: TokenGroupError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl ToStr for TokenGroupError {
fn to_str(&self) -> &'static str {
match self {
TokenGroupError::SizeExceedsNewMaxSize => "Size is greater than proposed max size",
TokenGroupError::SizeExceedsMaxSize => "Size is greater than max size",
TokenGroupError::ImmutableGroup => "Group is immutable",
TokenGroupError::IncorrectMintAuthority => {
"Incorrect mint authority has signed the instruction"
}
TokenGroupError::IncorrectUpdateAuthority => {
"Incorrect update authority has signed the instruction"
}
TokenGroupError::MemberAccountIsGroupAccount => {
"Member account should not be the same as the group account"
}
}
}
}