token_acl_interface/
error.rs

1use num_traits::FromPrimitive;
2use solana_program_error::ProgramError;
3use spl_tlv_account_resolution::error::AccountResolutionError;
4
5#[derive(Clone, Debug, PartialEq, thiserror::Error)]
6pub enum ThawFreezeGateError {
7    /// Incorrect account provided
8    //#[error("Incorrect account provided")]
9    IncorrectAccount,
10
11    //#[error("Missing AccountMeta in instruction")]
12    MissingAccountMeta,
13
14    //#[error("ExtraAccountMeta not found or empty")]
15    MissingExtraAccountMeta,
16
17    //#[error("Resolution error")]
18    ResolutionError(spl_tlv_account_resolution::error::AccountResolutionError),
19
20    ProgramError(ProgramError),
21
22    InvalidTokenMint,
23}
24
25impl std::fmt::Display for ThawFreezeGateError {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        write!(f, "{:?}", self)
28    }
29}
30
31impl Into<ThawFreezeGateError> for AccountResolutionError {
32    fn into(self) -> ThawFreezeGateError {
33        ThawFreezeGateError::ResolutionError(self)
34    }
35}
36
37impl Into<ThawFreezeGateError> for ProgramError {
38    fn into(self) -> ThawFreezeGateError {
39        match self {
40            ProgramError::Custom(code) => ThawFreezeGateError::ResolutionError(
41                AccountResolutionError::from_u32(code).unwrap(),
42            ),
43            _ => ThawFreezeGateError::ProgramError(self),
44        }
45    }
46}