Add ProgramError::CustomError and truncate value to 32 bytes
This commit is contained in:
committed by
Greg Fitzgerald
parent
56b0ba2601
commit
804378e8f7
@ -107,7 +107,14 @@ fn execute_instruction(
|
|||||||
executable_accounts,
|
executable_accounts,
|
||||||
program_accounts,
|
program_accounts,
|
||||||
tick_height,
|
tick_height,
|
||||||
)?;
|
)
|
||||||
|
.map_err(|err| match err {
|
||||||
|
ProgramError::CustomError(mut error) => {
|
||||||
|
error.truncate(32);
|
||||||
|
ProgramError::CustomError(error)
|
||||||
|
}
|
||||||
|
e => e,
|
||||||
|
})?;
|
||||||
|
|
||||||
// Verify the instruction
|
// Verify the instruction
|
||||||
for ((pre_program_id, pre_lamports, pre_userdata), post_account) in
|
for ((pre_program_id, pre_lamports, pre_userdata), post_account) in
|
||||||
|
@ -36,6 +36,12 @@ pub enum ProgramError {
|
|||||||
|
|
||||||
/// SystemInstruction::Assign was attempted on an account unowned by the system program
|
/// SystemInstruction::Assign was attempted on an account unowned by the system program
|
||||||
AssignOfUnownedAccount,
|
AssignOfUnownedAccount,
|
||||||
|
|
||||||
|
/// CustomError allows on-chain programs to implement program-specific error types and see
|
||||||
|
/// them returned by the Solana runtime. A CustomError may be any type that is serialized
|
||||||
|
/// to a Vec of bytes, max length 32 bytes. Any CustomError Vec greater than this length will
|
||||||
|
/// be truncated by the runtime.
|
||||||
|
CustomError(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for ProgramError {
|
impl std::fmt::Display for ProgramError {
|
||||||
|
Reference in New Issue
Block a user