mars/
error.rs

1use num_enum::IntoPrimitive;
2use solana_program::program_error::ProgramError;
3use thiserror::Error;
4
5#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
6#[repr(u32)]
7pub enum MarsError {
8    #[error("The starting time has not passed yet")]
9    NotStarted = 0,
10    #[error("The epoch has ended and needs reset")]
11    NeedsReset = 1,
12    #[error("The epoch is active and cannot be reset at this time")]
13    ResetTooEarly = 2,
14    #[error("The provided hash was invalid")]
15    HashInvalid = 3,
16    #[error("The provided hash does not satisfy the difficulty requirement")]
17    DifficultyNotSatisfied = 4,
18    #[error("The bus does not have enough rewards to issue at this time")]
19    BusRewardsInsufficient = 5,
20    #[error("The claim amount cannot be greater than the claimable rewards")]
21    ClaimTooLarge = 6,
22    #[error("The mining has ended")]
23    HasEnded = 7,
24}
25
26impl From<MarsError> for ProgramError {
27    fn from(e: MarsError) -> Self {
28        ProgramError::Custom(e as u32)
29    }
30}