1use thiserror::Error;
6
7#[derive(Debug, Error)]
9pub enum VineError {
10 #[error("Transport error: {0}")]
11 Transport(String),
12
13 #[error("Serialization error: {0}")]
14 Serialization(String),
15
16 #[error("Client not connected: {0}")]
17 ClientNotConnected(String),
18
19 #[error("Request timeout: {0}")]
20 Timeout(String),
21
22 #[error("Authentication error: {0}")]
23 Authentication(String),
24
25 #[error("Authorization error: {0}")]
26 Authorization(String),
27
28 #[error("Internal error: {0}")]
29 Internal(String),
30}
31
32impl From<tonic::transport::Error> for VineError {
33 fn from(err:tonic::transport::Error) -> Self { VineError::Transport(err.to_string()) }
34}
35
36impl From<serde_json::Error> for VineError {
37 fn from(err:serde_json::Error) -> Self { VineError::Serialization(err.to_string()) }
38}
39
40impl From<std::net::AddrParseError> for VineError {
41 fn from(err:std::net::AddrParseError) -> Self { VineError::Transport(format!("Invalid address: {}", err)) }
42}
43
44impl From<std::io::Error> for VineError {
45 fn from(err:std::io::Error) -> Self { VineError::Internal(err.to_string()) }
46}