spl_token_interface/
error.rs

1//! Error types
2
3use pinocchio::program_error::ProgramError;
4
5/// Errors that may be returned by the Token program.
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum TokenError {
8    // 0
9    /// Lamport balance below rent-exempt threshold.
10    NotRentExempt,
11    /// Insufficient funds for the operation requested.
12    InsufficientFunds,
13    /// Invalid Mint.
14    InvalidMint,
15    /// Account not associated with this Mint.
16    MintMismatch,
17    /// Owner does not match.
18    OwnerMismatch,
19
20    // 5
21    /// This token's supply is fixed and new tokens cannot be minted.
22    FixedSupply,
23    /// The account cannot be initialized because it is already being used.
24    AlreadyInUse,
25    /// Invalid number of provided signers.
26    InvalidNumberOfProvidedSigners,
27    /// Invalid number of required signers.
28    InvalidNumberOfRequiredSigners,
29    /// State is uninitialized.
30    UninitializedState,
31
32    // 10
33    /// Instruction does not support native tokens
34    NativeNotSupported,
35    /// Non-native account can only be closed if its balance is zero
36    NonNativeHasBalance,
37    /// Invalid instruction
38    InvalidInstruction,
39    /// State is invalid for requested operation.
40    InvalidState,
41    /// Operation overflowed
42    Overflow,
43
44    // 15
45    /// Account does not support specified authority type.
46    AuthorityTypeNotSupported,
47    /// This token mint cannot freeze accounts.
48    MintCannotFreeze,
49    /// Account is frozen; all account operations will fail
50    AccountFrozen,
51    /// Mint decimals mismatch between the client and mint
52    MintDecimalsMismatch,
53    /// Instruction does not support non-native tokens
54    NonNativeNotSupported,
55}
56
57impl From<TokenError> for ProgramError {
58    fn from(e: TokenError) -> Self {
59        ProgramError::Custom(e as u32)
60    }
61}