1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use num_derive::FromPrimitive;
use thiserror::Error;
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
pub type AoResult<T = ()> = Result<T, DexError>;
#[derive(Clone, Debug, Error, FromPrimitive)]
pub enum DexError {
#[error("The given order index is invalid.")]
InvalidOrderIndex,
#[error("The user account has reached its maximum capacity for open orders.")]
UserAccountFull,
#[error("The transaction has been aborted.")]
TransactionAborted,
#[error("A required user account is missing.")]
MissingUserAccount,
#[error("The specified order has not been found.")]
OrderNotFound,
#[error("The operation is a no-op")]
NoOp,
#[error("The user does not own enough lamports")]
OutofFunds,
#[error("The user account is still active")]
UserAccountStillActive,
#[error("Market is still active")]
MarketStillActive,
}
impl From<DexError> for ProgramError {
fn from(e: DexError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for DexError {
fn type_of() -> &'static str {
"AOError"
}
}