solidb_client/protocol/
error.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub enum DriverError {
5    ConnectionError(String),
6    ProtocolError(String),
7    DatabaseError(String),
8    AuthError(String),
9    TransactionError(String),
10    MessageTooLarge,
11    InvalidCommand(String),
12}
13
14impl std::fmt::Display for DriverError {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        match self {
17            DriverError::ConnectionError(msg) => write!(f, "Connection error: {}", msg),
18            DriverError::ProtocolError(msg) => write!(f, "Protocol error: {}", msg),
19            DriverError::DatabaseError(msg) => write!(f, "Database error: {}", msg),
20            DriverError::AuthError(msg) => write!(f, "Auth error: {}", msg),
21            DriverError::TransactionError(msg) => write!(f, "Transaction error: {}", msg),
22            DriverError::MessageTooLarge => write!(f, "Message too large"),
23            DriverError::InvalidCommand(msg) => write!(f, "Invalid command: {}", msg),
24        }
25    }
26}
27
28impl std::error::Error for DriverError {}