Custom errors
Define custom errors with#[error_code]:
Error codes
Custom errors start at code 6000:- First error: 6000
- Second error: 6001
- And so on…
Anchor framework errors
Common built-in errors:| Code | Error | Description |
|---|---|---|
| 100 | InstructionMissing | 8 byte instruction identifier not provided |
| 101 | InstructionFallbackNotFound | Fallback functions are not supported |
| 102 | InstructionDidNotDeserialize | The program could not deserialize the given instruction |
| 103 | InstructionDidNotSerialize | The program could not serialize the given instruction |
| 140 | ConstraintMut | A mut constraint was violated |
| 141 | ConstraintHasOne | A has_one constraint was violated |
| 142 | ConstraintSigner | A signer constraint was violated |
| 143 | ConstraintRaw | A raw constraint was violated |
| 144 | ConstraintOwner | An owner constraint was violated |
| 2000 | AccountDiscriminatorAlreadySet | The account discriminator is already set |
| 2001 | AccountDiscriminatorNotFound | No 8 byte discriminator was found |
| 2002 | AccountDiscriminatorMismatch | 8 byte discriminator did not match |
| 2003 | AccountDidNotDeserialize | Failed to deserialize the account |
| 2004 | AccountDidNotSerialize | Failed to serialize the account |
| 3000 | DeclaredProgramIdMismatch | The declared program id does not match |