escrow_api/
error.rs

1use steel::*;
2
3#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
4#[repr(u32)]
5pub enum EscrowError {
6    // Authority Errors
7    #[error("The authority is invalid")]
8    InvalidAuthority = 0,
9    #[error("The authority is unchanged")]
10    AuthorityUnchanged = 1,
11    #[error("Only the authority can perform this action")]
12    Unauthorized = 2,
13
14    // Payment State Errors
15    #[error("Payment is not in the correct state for this operation")]
16    InvalidPaymentState = 10,
17    #[error("Payment is already disputed")]
18    PaymentAlreadyDisputed = 11,
19    #[error("Payment is not disputed")]
20    PaymentNotDisputed = 12,
21    #[error("Payment is not arbitrated")]
22    PaymentNotArbitrated = 13,
23    #[error("Payment has already expired")]
24    PaymentExpired = 14,
25    #[error("Payment is not funded")]
26    PaymentNotFunded = 15,
27    #[error("Payment is already funded")]
28    PaymentAlreadyFunded = 16,
29    #[error("Payment is already released")]
30    PaymentAlreadyReleased = 17,
31    #[error("Payment is already refunded")]
32    PaymentAlreadyRefunded = 18,
33    #[error("Payment is already canceled")]
34    PaymentAlreadyCanceled = 19,
35
36    // Dispute Errors
37    #[error("Only buyer or seller can dispute this payment")]
38    InvalidDisputer = 20,
39    #[error("Invalid dispute reason")]
40    InvalidDisputeReason = 21,
41    #[error("Dispute already exists for this payment")]
42    DisputeAlreadyExists = 22,
43    #[error("Arbitration required for this dispute")]
44    ArbitrationRequired = 23,
45
46    // Escrow Errors
47    #[error("Escrow is paused")]
48    EscrowPaused = 30,
49    #[error("Escrow has non-zero balance")]
50    EscrowHasBalance = 31,
51    #[error("Escrow has non-zero fee balance")]
52    EscrowHasFeeBalance = 32,
53    #[error("Invalid escrow settings")]
54    InvalidEscrowSettings = 33,
55    #[error("Fee basis points too high")]
56    FeeTooHigh = 34,
57    #[error("Minimum payment amount must be greater than zero")]
58    InvalidMinPaymentAmount = 35,
59    #[error("Maximum payment amount must be greater than minimum")]
60    InvalidMaxPaymentAmount = 36,
61
62    // Amount Errors
63    #[error("Invalid amount for split decision")]
64    InvalidSplitAmount = 40,
65    #[error("Amount exceeds maximum payment limit")]
66    AmountExceedsLimit = 41,
67    #[error("Amount below minimum payment limit")]
68    AmountBelowLimit = 42,
69    #[error("Insufficient funds")]
70    InsufficientFunds = 43,
71    #[error("Insufficient storage balance for SOL operations")]
72    InsufficientStorageBalance = 44,
73
74    // TTL Errors
75    #[error("Invalid TTL extension")]
76    InvalidTTLExtension = 50,
77    #[error("TTL extension too large")]
78    TTLExtensionTooLarge = 51,
79    #[error("Payment cannot be canceled after expiration")]
80    CannotCancelExpiredPayment = 52,
81
82    // Account Errors
83    #[error("Invalid account provided")]
84    InvalidAccount = 60,
85    #[error("Account is not writable")]
86    AccountNotWritable = 61,
87    #[error("Account is not signer")]
88    AccountNotSigner = 62,
89    #[error("Account is not empty")]
90    AccountNotEmpty = 63,
91    #[error("Account is empty")]
92    AccountEmpty = 64,
93
94    // Token Errors
95    #[error("Invalid token account")]
96    InvalidTokenAccount = 70,
97    #[error("Token transfer failed")]
98    TokenTransferFailed = 71,
99    #[error("Token account close failed")]
100    TokenAccountCloseFailed = 72,
101
102    // Program Errors
103    #[error("Invalid program ID")]
104    InvalidProgramId = 80,
105    #[error("Invalid instruction data")]
106    InvalidInstructionData = 81,
107    #[error("Account not found")]
108    AccountNotFound = 82,
109    #[error("Not enough account keys")]
110    NotEnoughAccountKeys = 83,
111    #[error("Missing required field")]
112    MissingRequiredField = 84,
113    #[error("Cannot close active payment")]
114    CannotCloseActivePayment = 85,
115    #[error("Too early to close payment")]
116    TooEarlyToClose = 86,
117    #[error("Appeal window has expired")]
118    AppealWindowExpired = 87,
119    #[error("Maximum appeals reached")]
120    MaxAppealsReached = 88,
121}
122
123error!(EscrowError);