Attribute Macro spl_program_error::spl_program_error
source ยท #[spl_program_error]
Expand description
Proc macro attribute to turn your enum into a Solana Program Error
Adds:
Clone
Debug
Eq
PartialEq
thiserror::Error
num_derive::FromPrimitive
Into<solana_program::program_error::ProgramError>
solana_program::decode_error::DecodeError
solana_program::program_error::PrintProgramError
Optionally, you can add hash_error_code_start: u32
argument to create
a unique u32
starting error codes from the names of the enum variants.
Notes:
- The error variant will start at this value, and the rest will be incremented by one
- The value provided is only for code readability, the actual error code will be a hash of the input string and is checked against your input
Syntax: #[spl_program_error(hash_error_code_start = 1275525928)]
Hash Input: spl_program_error:<enum name>:<variant name>
Value: u32::from_le_bytes(<hash of input>[13..17])