Skip to main content

solmail_program/
error.rs

1use pinocchio::program_error::ProgramError;
2
3/// Custom error codes for SolMail program
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[repr(u32)]
6pub enum SolMailError {
7    /// Invalid instruction data
8    InvalidInstructionData = 0,
9    /// Missing required signature
10    MissingRequiredSignature = 1,
11    /// Invalid PDA derivation
12    InvalidPda = 2,
13    /// Unauthorized oracle
14    UnauthorizedOracle = 3,
15    /// Escrow already delivered
16    AlreadyDelivered = 4,
17    /// Timeout not reached for refund
18    TimeoutNotReached = 5,
19    /// Insufficient funds
20    InsufficientFunds = 6,
21    /// Amount below minimum
22    AmountBelowMinimum = 7,
23    /// Invalid token mint
24    InvalidMint = 8,
25    /// Account not writable
26    AccountNotWritable = 9,
27    /// Invalid account owner
28    InvalidAccountOwner = 10,
29    /// Arithmetic overflow
30    Overflow = 11,
31    /// Escrow not found
32    EscrowNotFound = 12,
33    /// Credits account not found
34    CreditsNotFound = 13,
35    /// Invalid payer
36    InvalidPayer = 14,
37}
38
39impl From<SolMailError> for ProgramError {
40    fn from(e: SolMailError) -> Self {
41        ProgramError::Custom(e as u32)
42    }
43}