error.rs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. use crate::error;
  2. /// Error codes that can be returned by internal framework code.
  3. ///
  4. /// - >= 100 Instruction error codes
  5. /// - >= 1000 IDL error codes
  6. /// - >= 2000 constraint error codes
  7. /// - >= 3000 account error codes
  8. /// - = 4000 state error code
  9. /// - = 5000 deprecated error code
  10. ///
  11. /// The starting point for user-defined errors is defined
  12. /// by the [ERROR_CODE_OFFSET](crate::__private::ERROR_CODE_OFFSET).
  13. #[error(offset = 0)]
  14. pub enum ErrorCode {
  15. // Instructions
  16. /// 100 - 8 byte instruction identifier not provided
  17. #[msg("8 byte instruction identifier not provided")]
  18. InstructionMissing = 100,
  19. /// 101 - Fallback functions are not supported
  20. #[msg("Fallback functions are not supported")]
  21. InstructionFallbackNotFound,
  22. /// 102 - The program could not deserialize the given instruction
  23. #[msg("The program could not deserialize the given instruction")]
  24. InstructionDidNotDeserialize,
  25. /// 103 - The program could not serialize the given instruction
  26. #[msg("The program could not serialize the given instruction")]
  27. InstructionDidNotSerialize,
  28. // IDL instructions
  29. /// 1000 - The program was compiled without idl instructions
  30. #[msg("The program was compiled without idl instructions")]
  31. IdlInstructionStub = 1000,
  32. /// 1001 - Invalid program given to the IDL instruction
  33. #[msg("Invalid program given to the IDL instruction")]
  34. IdlInstructionInvalidProgram,
  35. // Constraints
  36. /// 2000 - A mut constraint was violated
  37. #[msg("A mut constraint was violated")]
  38. ConstraintMut = 2000,
  39. /// 2001 - A has one constraint was violated
  40. #[msg("A has one constraint was violated")]
  41. ConstraintHasOne,
  42. /// 2002 - A signer constraint was violated
  43. #[msg("A signer constraint was violated")]
  44. ConstraintSigner,
  45. /// 2003 - A raw constraint was violated
  46. #[msg("A raw constraint was violated")]
  47. ConstraintRaw,
  48. /// 2004 - An owner constraint was violated
  49. #[msg("An owner constraint was violated")]
  50. ConstraintOwner,
  51. /// 2005 - A rent exemption constraint was violated
  52. #[msg("A rent exemption constraint was violated")]
  53. ConstraintRentExempt,
  54. /// 2006 - A seeds constraint was violated
  55. #[msg("A seeds constraint was violated")]
  56. ConstraintSeeds,
  57. /// 2007 - An executable constraint was violated
  58. #[msg("An executable constraint was violated")]
  59. ConstraintExecutable,
  60. /// 2008 - A state constraint was violated
  61. #[msg("A state constraint was violated")]
  62. ConstraintState,
  63. /// 2009 - An associated constraint was violated
  64. #[msg("An associated constraint was violated")]
  65. ConstraintAssociated,
  66. /// 2010 - An associated init constraint was violated
  67. #[msg("An associated init constraint was violated")]
  68. ConstraintAssociatedInit,
  69. /// 2011 - A close constraint was violated
  70. #[msg("A close constraint was violated")]
  71. ConstraintClose,
  72. /// 2012 - An address constraint was violated
  73. #[msg("An address constraint was violated")]
  74. ConstraintAddress,
  75. /// 2013 - Expected zero account discriminant
  76. #[msg("Expected zero account discriminant")]
  77. ConstraintZero,
  78. /// 2014 - A token mint constraint was violated
  79. #[msg("A token mint constraint was violated")]
  80. ConstraintTokenMint,
  81. /// 2015 - A token owner constraint was violated
  82. #[msg("A token owner constraint was violated")]
  83. ConstraintTokenOwner,
  84. /// The mint mint is intentional -> a mint authority for the mint.
  85. ///
  86. /// 2016 - A mint mint authority constraint was violated
  87. #[msg("A mint mint authority constraint was violated")]
  88. ConstraintMintMintAuthority,
  89. /// 2017 - A mint freeze authority constraint was violated
  90. #[msg("A mint freeze authority constraint was violated")]
  91. ConstraintMintFreezeAuthority,
  92. /// 2018 - A mint decimals constraint was violated
  93. #[msg("A mint decimals constraint was violated")]
  94. ConstraintMintDecimals,
  95. /// 2019 - A space constraint was violated
  96. #[msg("A space constraint was violated")]
  97. ConstraintSpace,
  98. // Accounts.
  99. /// 3000 - The account discriminator was already set on this account
  100. #[msg("The account discriminator was already set on this account")]
  101. AccountDiscriminatorAlreadySet = 3000,
  102. /// 3001 - No 8 byte discriminator was found on the account
  103. #[msg("No 8 byte discriminator was found on the account")]
  104. AccountDiscriminatorNotFound,
  105. /// 3002 - 8 byte discriminator did not match what was expected
  106. #[msg("8 byte discriminator did not match what was expected")]
  107. AccountDiscriminatorMismatch,
  108. /// 3003 - Failed to deserialize the account
  109. #[msg("Failed to deserialize the account")]
  110. AccountDidNotDeserialize,
  111. /// 3004 - Failed to serialize the account
  112. #[msg("Failed to serialize the account")]
  113. AccountDidNotSerialize,
  114. /// 3005 - Not enough account keys given to the instruction
  115. #[msg("Not enough account keys given to the instruction")]
  116. AccountNotEnoughKeys,
  117. /// 3006 - The given account is not mutable
  118. #[msg("The given account is not mutable")]
  119. AccountNotMutable,
  120. /// 3007 - The given account is owned by a different program than expected
  121. #[msg("The given account is owned by a different program than expected")]
  122. AccountOwnedByWrongProgram,
  123. /// 3008 - Program ID was not as expected
  124. #[msg("Program ID was not as expected")]
  125. InvalidProgramId,
  126. /// 3009 - Program account is not executable
  127. #[msg("Program account is not executable")]
  128. InvalidProgramExecutable,
  129. /// 3010 - The given account did not sign
  130. #[msg("The given account did not sign")]
  131. AccountNotSigner,
  132. /// 3011 - The given account is not owned by the system program
  133. #[msg("The given account is not owned by the system program")]
  134. AccountNotSystemOwned,
  135. /// 3012 - The program expected this account to be already initialized
  136. #[msg("The program expected this account to be already initialized")]
  137. AccountNotInitialized,
  138. /// 3013 - The given account is not a program data account
  139. #[msg("The given account is not a program data account")]
  140. AccountNotProgramData,
  141. /// 3014 - The given account is not the associated token account
  142. #[msg("The given account is not the associated token account")]
  143. AccountNotAssociatedTokenAccount,
  144. // State.
  145. /// 4000 - The given state account does not have the correct address
  146. #[msg("The given state account does not have the correct address")]
  147. StateInvalidAddress = 4000,
  148. // Deprecated
  149. /// 5000 - The API being used is deprecated and should no longer be used
  150. #[msg("The API being used is deprecated and should no longer be used")]
  151. Deprecated = 5000,
  152. }