1use solana_client::client_error::reqwest;
2use solana_sdk::{
3 instruction::InstructionError, program_error::ProgramError, pubkey::ParsePubkeyError,
4};
5
6use crate::pubsub_client::PubsubClientError;
7
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error("RPC error: {0}")]
11 RpcError(Box<solana_client::client_error::ClientError>),
12 #[error("Failed to parse bincode: {0}")]
13 ParseBincodeError(#[from] Box<bincode::ErrorKind>),
14 #[error("Anchor error: {0}")]
15 AnchorError(#[from] anchor_lang::error::Error),
16 #[error("Solana Pubsub error: {0}")]
17 SolanaPubsubError(Box<PubsubClientError>),
18 #[error("Program error: {0}")]
19 ProgramError(#[from] ProgramError),
20 #[error("Account required for the instruction was not found")]
21 AccountNotFound,
22 #[error("Invalid prepayment: {slots_immediately_for_auction} slots will immediately be auctioned off, but only {num_prepaid_segment_slots} prepaid slots were provided")]
23 InvalidPrepayment {
24 slots_immediately_for_auction: u64,
25 num_prepaid_segment_slots: u64,
26 },
27 #[error("Too many tasks")]
28 TooManyTasks,
29 #[error("Price arithmetic error")]
30 PriceArithmeticError,
31 #[error("Failed to fetch remote transaction: {0}")]
32 FetchRemoteTransactionError(#[from] reqwest::Error),
33 #[error("Failed to decode base64")]
34 DecodeBase64Error(#[from] base64::DecodeError),
35 #[error("Invalid transaction: {0}")]
36 InvalidTransaction(&'static str),
37 #[error("Failed to parse pubkey: {0}")]
38 ParsePubkeyError(#[from] ParsePubkeyError),
39 #[error("Not enough free tasks to construct transaction")]
40 NotEnoughFreeTasks,
41 #[error("Instruction error: {0}")]
42 InstructionError(#[from] InstructionError),
43 #[error("Clock send error")]
44 ClockSendError,
45}
46
47impl From<solana_client::client_error::ClientError> for Error {
48 fn from(value: solana_client::client_error::ClientError) -> Self {
49 Self::RpcError(Box::new(value))
50 }
51}
52
53impl From<PubsubClientError> for Error {
54 fn from(value: PubsubClientError) -> Self {
55 Self::SolanaPubsubError(Box::new(value))
56 }
57}