use spl_program_error::*;
#[derive(Clone, Debug, Eq, thiserror::Error, num_derive::FromPrimitive, PartialEq)]
pub enum ExampleError {
#[error("Mint has no mint authority")]
MintHasNoMintAuthority,
#[error("Incorrect mint authority has signed the instruction")]
IncorrectMintAuthority,
}
impl From<ExampleError> for solana_program_error::ProgramError {
fn from(e: ExampleError) -> Self {
solana_program_error::ProgramError::Custom(e as u32)
}
}
impl solana_program_error::ToStr for ExampleError {
fn to_str(&self) -> &'static str {
match self {
ExampleError::MintHasNoMintAuthority => "Mint has no mint authority",
ExampleError::IncorrectMintAuthority => {
"Incorrect mint authority has signed the instruction"
}
}
}
}
#[test]
fn test_macros_compile() {
let _ = ExampleError::MintHasNoMintAuthority;
}