lightcone_sdk/program/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum SdkError {
8 #[error("RPC error: {0}")]
10 Rpc(#[from] solana_client::client_error::ClientError),
11
12 #[error("Invalid account discriminator: expected {expected}, got {actual}")]
14 InvalidDiscriminator {
15 expected: String,
16 actual: String,
17 },
18
19 #[error("Account not found: {0}")]
21 AccountNotFound(String),
22
23 #[error("Invalid data length: expected {expected}, got {actual}")]
25 InvalidDataLength {
26 expected: usize,
27 actual: usize,
28 },
29
30 #[error("Invalid order hash")]
32 InvalidOrderHash,
33
34 #[error("Invalid signature")]
36 InvalidSignature,
37
38 #[error("Order expired")]
40 OrderExpired,
41
42 #[error("Invalid outcome count: {count} (must be {min}-{max})", min = crate::program::constants::MIN_OUTCOMES, max = crate::program::constants::MAX_OUTCOMES)]
44 InvalidOutcomeCount { count: u8 },
45
46 #[error("Invalid outcome index: {index} (max {max})")]
48 InvalidOutcomeIndex {
49 index: u8,
50 max: u8,
51 },
52
53 #[error("Too many makers: {count} (max {max})", max = crate::program::constants::MAX_MAKERS)]
55 TooManyMakers { count: usize },
56
57 #[error("Serialization error: {0}")]
59 Serialization(String),
60
61 #[error("Invalid side value: {0} (must be 0 or 1)")]
63 InvalidSide(u8),
64
65 #[error("Invalid market status: {0}")]
67 InvalidMarketStatus(u8),
68
69 #[error("Signature verification failed")]
71 SignatureVerificationFailed,
72
73 #[error("Missing required field: {0}")]
75 MissingField(String),
76
77 #[error("Orders do not cross (prices incompatible)")]
79 OrdersDoNotCross,
80
81 #[error("Fill amount {fill} exceeds remaining {remaining}")]
83 FillAmountExceedsRemaining {
84 fill: u64,
85 remaining: u64,
86 },
87
88 #[error("Arithmetic overflow")]
90 Overflow,
91
92 #[error("Invalid pubkey: {0}")]
94 InvalidPubkey(String),
95}
96
97pub type SdkResult<T> = Result<T, SdkError>;