Skip to main content

clankerdiff_client/
error.rs

1use crate::protocol::shared::{ProtocolError, RemoteError};
2use thiserror::Error;
3
4#[derive(Debug, Clone, Error)]
5pub enum ClientError {
6    #[error("connection closed")]
7    Disconnected,
8    #[error("command may have completed before the connection was lost; verify before retrying")]
9    OutcomeUnknown,
10    #[error("protocol error: {0}")]
11    Protocol(String),
12    #[error("transport error: {0}")]
13    Transport(String),
14    #[error(transparent)]
15    Remote(#[from] RemoteError),
16}
17
18impl From<ProtocolError> for ClientError {
19    fn from(error: ProtocolError) -> Self {
20        Self::Protocol(error.to_string())
21    }
22}
23
24#[cfg(feature = "websocket")]
25pub(crate) fn transport(error: impl ToString) -> ClientError {
26    let message = error.to_string();
27    drop(error);
28    ClientError::Transport(message)
29}