modeldriveprotocol_client/
error.rs1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum MdpClientError {
5 #[error("transport error: {0}")]
6 Transport(String),
7 #[error("protocol error: {0}")]
8 Protocol(String),
9 #[error("invalid path: {0}")]
10 InvalidPath(String),
11 #[error("MDP client is not connected")]
12 NotConnected,
13 #[error("MDP client is not registered")]
14 NotRegistered,
15 #[error("unknown path `{path}` for method `{method}`")]
16 UnknownPath { path: String, method: String },
17 #[error("handler error: {0}")]
18 Handler(String),
19}
20
21impl From<serde_json::Error> for MdpClientError {
22 fn from(value: serde_json::Error) -> Self {
23 Self::Protocol(value.to_string())
24 }
25}
26
27impl From<reqwest::Error> for MdpClientError {
28 fn from(value: reqwest::Error) -> Self {
29 Self::Transport(value.to_string())
30 }
31}
32
33impl From<tokio_tungstenite::tungstenite::Error> for MdpClientError {
34 fn from(value: tokio_tungstenite::tungstenite::Error) -> Self {
35 Self::Transport(value.to_string())
36 }
37}