use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
InvalidPubkey(String),
InvalidAccountData(String),
Transport(String),
Rpc {
code: i64,
message: String,
},
UnexpectedResponse(String),
AccountNotFound(String),
InvalidSeeds(&'static str),
InvalidArgument(String),
Encode(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::InvalidPubkey(s) => write!(f, "invalid pubkey: {s}"),
Error::InvalidAccountData(s) => write!(f, "invalid account data: {s}"),
Error::Transport(s) => write!(f, "transport error: {s}"),
Error::Rpc { code, message } => write!(f, "rpc error {code}: {message}"),
Error::UnexpectedResponse(s) => write!(f, "unexpected rpc response: {s}"),
Error::AccountNotFound(s) => write!(f, "account not found: {s}"),
Error::InvalidSeeds(s) => write!(f, "invalid seeds: {s}"),
Error::InvalidArgument(s) => write!(f, "invalid argument: {s}"),
Error::Encode(s) => write!(f, "encode error: {s}"),
}
}
}
impl std::error::Error for Error {}
pub type Result<T> = core::result::Result<T, Error>;