2021-06-09 13:02:50 -07:00
|
|
|
use crate::error;
|
2021-01-15 23:05:26 -08:00
|
|
|
|
2022-02-10 12:54:12 -08:00
|
|
|
/// The starting point for user defined error codes.
|
|
|
|
pub const ERROR_CODE_OFFSET: u32 = 6000;
|
|
|
|
|
2021-12-30 17:46:49 -08:00
|
|
|
/// Error codes that can be returned by internal framework code.
|
|
|
|
///
|
|
|
|
/// - >= 100 Instruction error codes
|
|
|
|
/// - >= 1000 IDL error codes
|
|
|
|
/// - >= 2000 constraint error codes
|
|
|
|
/// - >= 3000 account error codes
|
|
|
|
/// - = 4000 state error code
|
|
|
|
/// - = 5000 deprecated error code
|
|
|
|
///
|
|
|
|
/// The starting point for user-defined errors is defined
|
2022-02-10 12:54:12 -08:00
|
|
|
/// by the [ERROR_CODE_OFFSET](crate::error::ERROR_CODE_OFFSET).
|
2021-06-09 13:02:50 -07:00
|
|
|
#[error(offset = 0)]
|
2021-01-15 23:05:26 -08:00
|
|
|
pub enum ErrorCode {
|
2021-12-30 17:46:49 -08:00
|
|
|
// Instructions
|
|
|
|
/// 100 - 8 byte instruction identifier not provided
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("8 byte instruction identifier not provided")]
|
|
|
|
InstructionMissing = 100,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 101 - Fallback functions are not supported
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("Fallback functions are not supported")]
|
|
|
|
InstructionFallbackNotFound,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 102 - The program could not deserialize the given instruction
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The program could not deserialize the given instruction")]
|
|
|
|
InstructionDidNotDeserialize,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 103 - The program could not serialize the given instruction
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The program could not serialize the given instruction")]
|
|
|
|
InstructionDidNotSerialize,
|
2021-01-15 23:05:26 -08:00
|
|
|
|
2021-12-30 17:46:49 -08:00
|
|
|
// IDL instructions
|
|
|
|
/// 1000 - The program was compiled without idl instructions
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The program was compiled without idl instructions")]
|
2021-12-08 13:50:08 -08:00
|
|
|
IdlInstructionStub = 1000,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 1001 - Invalid program given to the IDL instruction
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("Invalid program given to the IDL instruction")]
|
|
|
|
IdlInstructionInvalidProgram,
|
|
|
|
|
2021-12-30 17:46:49 -08:00
|
|
|
// Constraints
|
|
|
|
/// 2000 - A mut constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("A mut constraint was violated")]
|
2021-12-08 13:50:08 -08:00
|
|
|
ConstraintMut = 2000,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2001 - A has one constraint was violated
|
2021-07-03 11:58:23 -07:00
|
|
|
#[msg("A has one constraint was violated")]
|
|
|
|
ConstraintHasOne,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2002 - A signer constraint was violated
|
2021-12-21 11:13:51 -08:00
|
|
|
#[msg("A signer constraint was violated")]
|
2021-06-09 13:02:50 -07:00
|
|
|
ConstraintSigner,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2003 - A raw constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("A raw constraint was violated")]
|
|
|
|
ConstraintRaw,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2004 - An owner constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("An owner constraint was violated")]
|
|
|
|
ConstraintOwner,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2005 - A rent exemption constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("A rent exemption constraint was violated")]
|
|
|
|
ConstraintRentExempt,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2006 - A seeds constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("A seeds constraint was violated")]
|
|
|
|
ConstraintSeeds,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2007 - An executable constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("An executable constraint was violated")]
|
|
|
|
ConstraintExecutable,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2008 - A state constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("A state constraint was violated")]
|
|
|
|
ConstraintState,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2009 - An associated constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("An associated constraint was violated")]
|
|
|
|
ConstraintAssociated,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2010 - An associated init constraint was violated
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("An associated init constraint was violated")]
|
|
|
|
ConstraintAssociatedInit,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2011 - A close constraint was violated
|
2021-06-09 15:40:43 -07:00
|
|
|
#[msg("A close constraint was violated")]
|
|
|
|
ConstraintClose,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2012 - An address constraint was violated
|
2021-06-27 13:17:05 -07:00
|
|
|
#[msg("An address constraint was violated")]
|
|
|
|
ConstraintAddress,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2013 - Expected zero account discriminant
|
2021-08-29 14:25:38 -07:00
|
|
|
#[msg("Expected zero account discriminant")]
|
|
|
|
ConstraintZero,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2014 - A token mint constraint was violated
|
2021-12-08 13:50:08 -08:00
|
|
|
#[msg("A token mint constraint was violated")]
|
|
|
|
ConstraintTokenMint,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2015 - A token owner constraint was violated
|
2021-12-08 13:50:08 -08:00
|
|
|
#[msg("A token owner constraint was violated")]
|
|
|
|
ConstraintTokenOwner,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// The mint mint is intentional -> a mint authority for the mint.
|
|
|
|
///
|
|
|
|
/// 2016 - A mint mint authority constraint was violated
|
2021-12-08 13:50:08 -08:00
|
|
|
#[msg("A mint mint authority constraint was violated")]
|
|
|
|
ConstraintMintMintAuthority,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2017 - A mint freeze authority constraint was violated
|
2021-12-08 13:50:08 -08:00
|
|
|
#[msg("A mint freeze authority constraint was violated")]
|
|
|
|
ConstraintMintFreezeAuthority,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2018 - A mint decimals constraint was violated
|
2021-12-08 13:50:08 -08:00
|
|
|
#[msg("A mint decimals constraint was violated")]
|
|
|
|
ConstraintMintDecimals,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 2019 - A space constraint was violated
|
2021-12-08 13:50:08 -08:00
|
|
|
#[msg("A space constraint was violated")]
|
|
|
|
ConstraintSpace,
|
2021-06-09 13:02:50 -07:00
|
|
|
|
|
|
|
// Accounts.
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3000 - The account discriminator was already set on this account
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The account discriminator was already set on this account")]
|
2021-12-08 13:50:08 -08:00
|
|
|
AccountDiscriminatorAlreadySet = 3000,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3001 - No 8 byte discriminator was found on the account
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("No 8 byte discriminator was found on the account")]
|
|
|
|
AccountDiscriminatorNotFound,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3002 - 8 byte discriminator did not match what was expected
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("8 byte discriminator did not match what was expected")]
|
|
|
|
AccountDiscriminatorMismatch,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3003 - Failed to deserialize the account
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("Failed to deserialize the account")]
|
|
|
|
AccountDidNotDeserialize,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3004 - Failed to serialize the account
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("Failed to serialize the account")]
|
|
|
|
AccountDidNotSerialize,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3005 - Not enough account keys given to the instruction
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("Not enough account keys given to the instruction")]
|
|
|
|
AccountNotEnoughKeys,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3006 - The given account is not mutable
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The given account is not mutable")]
|
|
|
|
AccountNotMutable,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3007 - The given account is owned by a different program than expected
|
2021-12-17 04:34:43 -08:00
|
|
|
#[msg("The given account is owned by a different program than expected")]
|
|
|
|
AccountOwnedByWrongProgram,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3008 - Program ID was not as expected
|
2021-09-11 14:43:12 -07:00
|
|
|
#[msg("Program ID was not as expected")]
|
|
|
|
InvalidProgramId,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3009 - Program account is not executable
|
2021-09-11 14:43:12 -07:00
|
|
|
#[msg("Program account is not executable")]
|
|
|
|
InvalidProgramExecutable,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3010 - The given account did not sign
|
2021-09-11 14:43:12 -07:00
|
|
|
#[msg("The given account did not sign")]
|
|
|
|
AccountNotSigner,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3011 - The given account is not owned by the system program
|
2021-10-30 09:45:06 -07:00
|
|
|
#[msg("The given account is not owned by the system program")]
|
|
|
|
AccountNotSystemOwned,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3012 - The program expected this account to be already initialized
|
2021-11-18 07:42:07 -08:00
|
|
|
#[msg("The program expected this account to be already initialized")]
|
|
|
|
AccountNotInitialized,
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 3013 - The given account is not a program data account
|
2021-12-05 11:14:16 -08:00
|
|
|
#[msg("The given account is not a program data account")]
|
|
|
|
AccountNotProgramData,
|
2022-01-01 18:47:13 -08:00
|
|
|
/// 3014 - The given account is not the associated token account
|
|
|
|
#[msg("The given account is not the associated token account")]
|
|
|
|
AccountNotAssociatedTokenAccount,
|
2021-01-15 23:05:26 -08:00
|
|
|
|
2021-06-09 13:02:50 -07:00
|
|
|
// State.
|
2021-12-30 17:46:49 -08:00
|
|
|
/// 4000 - The given state account does not have the correct address
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The given state account does not have the correct address")]
|
2021-12-08 13:50:08 -08:00
|
|
|
StateInvalidAddress = 4000,
|
2021-01-15 23:05:26 -08:00
|
|
|
|
2022-02-15 15:16:06 -08:00
|
|
|
// Miscellaneous
|
|
|
|
/// 4100 - The declared program id does not match actual program id
|
|
|
|
#[msg("The declared program id does not match the actual program id")]
|
|
|
|
DeclaredProgramIdMismatch = 4100,
|
|
|
|
|
2021-12-30 17:46:49 -08:00
|
|
|
// Deprecated
|
|
|
|
/// 5000 - The API being used is deprecated and should no longer be used
|
2021-06-09 13:02:50 -07:00
|
|
|
#[msg("The API being used is deprecated and should no longer be used")]
|
2021-12-08 13:50:08 -08:00
|
|
|
Deprecated = 5000,
|
2021-01-15 23:05:26 -08:00
|
|
|
}
|