use solana_address::Address;
use solana_instruction::error::InstructionError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum InvalidSysvarDataError {
#[error("Invalid Clock sysvar data.")]
Clock,
#[error("Invalid EpochRewards sysvar data.")]
EpochRewards,
#[error("Invalid EpochSchedule sysvar data.")]
EpochSchedule,
#[error("Invalid Fees sysvar data.")]
Fees,
#[error("Invalid LastRestartSlot sysvar data.")]
LastRestartSlot,
#[error("Invalid RecentBlockhashes sysvar data.")]
RecentBlockhashes,
#[error("Invalid Rent sysvar data.")]
Rent,
#[error("Invalid SlotHashes sysvar data.")]
SlotHashes,
#[error("Invalid StakeHistory sysvar data.")]
StakeHistory,
}
#[derive(Error, Debug)]
pub enum HPSVMError {
#[error("{0}")]
InvalidSysvarData(#[from] InvalidSysvarDataError),
#[error("failed to serialize sysvar {sysvar}: {reason}")]
SysvarSerialization { sysvar: &'static str, reason: String },
#[error("{0}")]
Instruction(#[from] InstructionError),
#[error("{0}")]
InvalidPath(#[from] std::io::Error),
#[error("failed to refresh runtime environment {version}: {reason}")]
RuntimeEnvironment { version: &'static str, reason: String },
#[error("failed to register custom syscall {name} in {runtime}: {reason}")]
CustomSyscallRegistration { name: String, runtime: &'static str, reason: String },
#[error("unsupported loader {loader_id} for program {program_id}")]
InvalidLoader { program_id: Address, loader_id: Address },
}