use thiserror::Error;
use tokio::sync::oneshot;
use tokio_tungstenite::tungstenite;
#[derive(Error, Debug)]
pub enum CommandError {
#[error("Serialization error: {0}.")]
SerdeError(#[from] serde_json::Error),
#[error("Missing command ID field.")]
MissingCommandId,
#[error("WebSocket send error: {0}.")]
WebSocketSendError(#[from] tungstenite::Error),
#[error("Missing result field.")]
MissingResult,
#[error("Command returned error: {0}")]
Error(serde_json::Value),
#[error("Timeout waiting for receiver response")]
TimeoutError,
#[error("Oneshot receiver error: {0}.")]
OneshotReceiverError(#[from] oneshot::error::RecvError),
#[error("Command error: {0}.")]
Other(String),
}
#[derive(Error, Debug)]
pub enum SessionError {
#[error("HTTP request error: {0}.")]
HttpRequestError(#[from] reqwest::Error),
#[error("Session response error: {0}.")]
SessionResponseError(String),
#[error("Session error: {0}.")]
Other(String),
}