1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use crate::error;

// Error codes that can be returned by internal framework code.
#[error(offset = 0)]
pub enum ErrorCode {
    // Instructions.
    #[msg("8 byte instruction identifier not provided")]
    InstructionMissing = 100,
    #[msg("Fallback functions are not supported")]
    InstructionFallbackNotFound,
    #[msg("The program could not deserialize the given instruction")]
    InstructionDidNotDeserialize,
    #[msg("The program could not serialize the given instruction")]
    InstructionDidNotSerialize,

    // IDL instructions.
    #[msg("The program was compiled without idl instructions")]
    IdlInstructionStub = 1000,
    #[msg("Invalid program given to the IDL instruction")]
    IdlInstructionInvalidProgram,

    // Constraints.
    #[msg("A mut constraint was violated")]
    ConstraintMut = 2000,
    #[msg("A has one constraint was violated")]
    ConstraintHasOne,
    #[msg("A signer constraint as violated")]
    ConstraintSigner,
    #[msg("A raw constraint was violated")]
    ConstraintRaw,
    #[msg("An owner constraint was violated")]
    ConstraintOwner,
    #[msg("A rent exemption constraint was violated")]
    ConstraintRentExempt,
    #[msg("A seeds constraint was violated")]
    ConstraintSeeds,
    #[msg("An executable constraint was violated")]
    ConstraintExecutable,
    #[msg("A state constraint was violated")]
    ConstraintState,
    #[msg("An associated constraint was violated")]
    ConstraintAssociated,
    #[msg("An associated init constraint was violated")]
    ConstraintAssociatedInit,
    #[msg("A close constraint was violated")]
    ConstraintClose,
    #[msg("An address constraint was violated")]
    ConstraintAddress,
    #[msg("Expected zero account discriminant")]
    ConstraintZero,
    #[msg("A token mint constraint was violated")]
    ConstraintTokenMint,
    #[msg("A token owner constraint was violated")]
    ConstraintTokenOwner,
    // The mint mint is intentional -> a mint authority for the mint.
    #[msg("A mint mint authority constraint was violated")]
    ConstraintMintMintAuthority,
    #[msg("A mint freeze authority constraint was violated")]
    ConstraintMintFreezeAuthority,
    #[msg("A mint decimals constraint was violated")]
    ConstraintMintDecimals,
    #[msg("A space constraint was violated")]
    ConstraintSpace,

    // Accounts.
    #[msg("The account discriminator was already set on this account")]
    AccountDiscriminatorAlreadySet = 3000,
    #[msg("No 8 byte discriminator was found on the account")]
    AccountDiscriminatorNotFound,
    #[msg("8 byte discriminator did not match what was expected")]
    AccountDiscriminatorMismatch,
    #[msg("Failed to deserialize the account")]
    AccountDidNotDeserialize,
    #[msg("Failed to serialize the account")]
    AccountDidNotSerialize,
    #[msg("Not enough account keys given to the instruction")]
    AccountNotEnoughKeys,
    #[msg("The given account is not mutable")]
    AccountNotMutable,
    #[msg("The given account is not owned by the executing program")]
    AccountNotProgramOwned,
    #[msg("Program ID was not as expected")]
    InvalidProgramId,
    #[msg("Program account is not executable")]
    InvalidProgramExecutable,
    #[msg("The given account did not sign")]
    AccountNotSigner,
    #[msg("The given account is not owned by the system program")]
    AccountNotSystemOwned,
    #[msg("The program expected this account to be already initialized")]
    AccountNotInitialized,
    #[msg("The given account is not a program data account")]
    AccountNotProgramData,

    // State.
    #[msg("The given state account does not have the correct address")]
    StateInvalidAddress = 4000,

    // Used for APIs that shouldn't be used anymore.
    #[msg("The API being used is deprecated and should no longer be used")]
    Deprecated = 5000,
}