use thiserror::Error;
#[derive(Error, Debug)]
pub enum ClientError {
#[error("RPC error: {0}")]
Rpc(String),
#[error("Transport error: {0}")]
Transport(String),
#[error("Validation error: {0}")]
Validation(String),
#[error("Transaction submission error: {0}")]
TransactionSubmission(String),
#[error("Transaction verification error: {0}")]
TransactionVerification(String),
#[error("Account not found: {0}")]
AccountNotFound(String),
#[error("{message}")]
Generic { message: String },
}
impl From<anyhow::Error> for ClientError {
fn from(err: anyhow::Error) -> Self {
ClientError::Generic {
message: err.to_string(),
}
}
}
impl From<tonic::Status> for ClientError {
fn from(status: tonic::Status) -> Self {
ClientError::Rpc(status.to_string())
}
}
impl From<tonic::transport::Error> for ClientError {
fn from(err: tonic::transport::Error) -> Self {
ClientError::Transport(err.to_string())
}
}