spl_transfer_hook_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 TransferHookError {
9 #[error("Incorrect account provided")]
11 IncorrectAccount = 2_110_272_652,
12 #[error("Mint has no mint authority")]
14 MintHasNoMintAuthority,
15 #[error("Incorrect mint authority has signed the instruction")]
17 IncorrectMintAuthority,
18 #[error("Program called outside of a token transfer")]
20 ProgramCalledOutsideOfTransfer,
21}
22
23impl From<TransferHookError> for ProgramError {
24 fn from(e: TransferHookError) -> Self {
25 ProgramError::Custom(e as u32)
26 }
27}
28
29impl ToStr for TransferHookError {
30 fn to_str(&self) -> &'static str {
31 match self {
32 TransferHookError::IncorrectAccount => "Incorrect account provided",
33 TransferHookError::MintHasNoMintAuthority => "Mint has no mint authority",
34 TransferHookError::IncorrectMintAuthority => {
35 "Incorrect mint authority has signed the instruction"
36 }
37 TransferHookError::ProgramCalledOutsideOfTransfer => {
38 "Program called outside of a token transfer"
39 }
40 }
41 }
42}