coal_api/
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 CoalError {
8    #[error("The epoch has ended and needs reset")]
9    NeedsReset = 0,
10    #[error("The provided hash is invalid")]
11    HashInvalid = 1,
12    #[error("The provided hash did not satisfy the minimum required difficulty")]
13    HashTooEasy = 2,
14    #[error("The claim amount cannot be greater than the claimable rewards")]
15    ClaimTooLarge = 3,
16    #[error("The clock time is invalid")]
17    ClockInvalid = 4,
18    #[error("You are trying to submit too soon")]
19    Spam = 5,
20    #[error("The maximum supply has been reached")]
21    MaxSupply = 6,
22    #[error("The proof does not match the expected account")]
23    AuthFailed = 7,
24    #[error("Slot too early")]
25    SlotTooEarly = 8,
26    #[error("The resource is invalid")]
27    InvalidResource = 9,
28}
29
30impl From<CoalError> for ProgramError {
31    fn from(e: CoalError) -> Self {
32        ProgramError::Custom(e as u32)
33    }
34}