error.rs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. use crate::error;
  2. // Error codes that can be returned by internal framework code.
  3. #[error(offset = 0)]
  4. pub enum ErrorCode {
  5. // Instructions.
  6. #[msg("8 byte instruction identifier not provided")]
  7. InstructionMissing = 100,
  8. #[msg("Fallback functions are not supported")]
  9. InstructionFallbackNotFound,
  10. #[msg("The program could not deserialize the given instruction")]
  11. InstructionDidNotDeserialize,
  12. #[msg("The program could not serialize the given instruction")]
  13. InstructionDidNotSerialize,
  14. // IDL instructions.
  15. #[msg("The program was compiled without idl instructions")]
  16. IdlInstructionStub = 120,
  17. #[msg("Invalid program given to the IDL instruction")]
  18. IdlInstructionInvalidProgram,
  19. // Constraints.
  20. #[msg("A mut constraint was violated")]
  21. ConstraintMut = 140,
  22. #[msg("A has one constraint was violated")]
  23. ConstraintHasOne,
  24. #[msg("A signer constraint as violated")]
  25. ConstraintSigner,
  26. #[msg("A raw constraint was violated")]
  27. ConstraintRaw,
  28. #[msg("An owner constraint was violated")]
  29. ConstraintOwner,
  30. #[msg("A rent exemption constraint was violated")]
  31. ConstraintRentExempt,
  32. #[msg("A seeds constraint was violated")]
  33. ConstraintSeeds,
  34. #[msg("An executable constraint was violated")]
  35. ConstraintExecutable,
  36. #[msg("A state constraint was violated")]
  37. ConstraintState,
  38. #[msg("An associated constraint was violated")]
  39. ConstraintAssociated,
  40. #[msg("An associated init constraint was violated")]
  41. ConstraintAssociatedInit,
  42. #[msg("A close constraint was violated")]
  43. ConstraintClose,
  44. #[msg("An address constraint was violated")]
  45. ConstraintAddress,
  46. // Accounts.
  47. #[msg("The account discriminator was already set on this account")]
  48. AccountDiscriminatorAlreadySet = 160,
  49. #[msg("No 8 byte discriminator was found on the account")]
  50. AccountDiscriminatorNotFound,
  51. #[msg("8 byte discriminator did not match what was expected")]
  52. AccountDiscriminatorMismatch,
  53. #[msg("Failed to deserialize the account")]
  54. AccountDidNotDeserialize,
  55. #[msg("Failed to serialize the account")]
  56. AccountDidNotSerialize,
  57. #[msg("Not enough account keys given to the instruction")]
  58. AccountNotEnoughKeys,
  59. #[msg("The given account is not mutable")]
  60. AccountNotMutable,
  61. #[msg("The given account is not owned by the executing program")]
  62. AccountNotProgramOwned,
  63. // State.
  64. #[msg("The given state account does not have the correct address")]
  65. StateInvalidAddress = 180,
  66. // Used for APIs that shouldn't be used anymore.
  67. #[msg("The API being used is deprecated and should no longer be used")]
  68. Deprecated = 299,
  69. }