pump_rust_client/
errors.rs1use solana_program::pubkey::Pubkey;
4
5#[derive(Debug)]
6pub enum PumpClientError {
7 Decode(Box<anchor_lang::error::Error>),
9 #[cfg(feature = "client")]
12 Rpc(Box<solana_client::client_error::ClientError>),
13 AccountNotFound { name: &'static str, address: Pubkey },
15}
16
17impl std::fmt::Display for PumpClientError {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 match self {
20 Self::Decode(e) => write!(f, "anchor decode error: {e}"),
21 #[cfg(feature = "client")]
22 Self::Rpc(e) => write!(f, "rpc error: {e}"),
23 Self::AccountNotFound { name, address } => {
24 write!(f, "account not found ({name}): {address}")
25 }
26 }
27 }
28}
29
30impl std::error::Error for PumpClientError {
31 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
32 match self {
33 Self::Decode(e) => Some(&**e),
34 #[cfg(feature = "client")]
35 Self::Rpc(e) => Some(&**e),
36 Self::AccountNotFound { .. } => None,
37 }
38 }
39}
40
41impl From<anchor_lang::error::Error> for PumpClientError {
42 fn from(e: anchor_lang::error::Error) -> Self {
43 Self::Decode(Box::new(e))
44 }
45}
46
47#[cfg(feature = "client")]
48impl From<solana_client::client_error::ClientError> for PumpClientError {
49 fn from(e: solana_client::client_error::ClientError) -> Self {
50 Self::Rpc(Box::new(e))
51 }
52}
53
54pub type Result<T> = std::result::Result<T, PumpClientError>;