Skip to main content

wp_solana_pool_traits/
error.rs

1//! Shared error types for pool protocol SDKs.
2//!
3//! Protocol-specific error enums can nest [`PoolError`] via `#[from]` to
4//! inherit these common variants while adding their own.
5
6use thiserror::Error;
7
8/// Protocol-agnostic errors shared by all pool SDKs.
9#[derive(Error, Debug)]
10pub enum PoolError {
11    /// A math operation failed (overflow, division by zero, etc.).
12    #[error("math error: {0}")]
13    Math(String),
14
15    /// The pool's on-chain state is invalid or inconsistent.
16    #[error("invalid pool state: {0}")]
17    InvalidPoolState(String),
18
19    /// The position data is invalid or does not exist.
20    #[error("invalid position: {0}")]
21    InvalidPosition(String),
22
23    /// Not enough liquidity for the requested operation.
24    #[error("insufficient liquidity: {0}")]
25    InsufficientLiquidity(String),
26
27    /// The price is outside the acceptable range.
28    #[error("price out of range: {0}")]
29    PriceOutOfRange(String),
30
31    /// A transparent wrapper for other errors.
32    #[error(transparent)]
33    Other(#[from] anyhow::Error),
34}