pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("WebSocket connection error: {0}")]
Connection(String),
#[error("Failed to send WebSocket message: {0}")]
Send(String),
#[error("Failed to receive WebSocket message: {0}")]
Receive(String),
#[error("Protocol error: {0}")]
Protocol(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Deserialization error: {0}")]
Deserialization(String),
#[error("Compression error: {0}")]
Compression(String),
#[error("Decompression error: {0}")]
Decompression(String),
#[error("Subscription error: {0}")]
Subscription(String),
#[error("Authentication failed: {0}")]
Authentication(String),
#[error("Authorization failed: {0}")]
Authorization(String),
#[error("Rate limit exceeded: {0}")]
RateLimit(String),
#[error("Invalid message: {0}")]
InvalidMessage(String),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("Resource not found: {0}")]
NotFound(String),
#[error("Server error: {0}")]
Server(String),
#[error("Client error: {0}")]
Client(String),
#[error("Operation timed out: {0}")]
Timeout(String),
#[error("Channel send error")]
ChannelSend,
#[error("Channel receive error")]
ChannelReceive,
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("OxiGDAL error: {0}")]
Core(String),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("MessagePack error: {0}")]
MessagePack(String),
#[error("Axum error: {0}")]
Axum(String),
#[error("Other error: {0}")]
Other(String),
}
impl From<axum::Error> for Error {
fn from(err: axum::Error) -> Self {
Error::Axum(err.to_string())
}
}
impl From<rmp_serde::encode::Error> for Error {
fn from(err: rmp_serde::encode::Error) -> Self {
Error::MessagePack(err.to_string())
}
}
impl From<rmp_serde::decode::Error> for Error {
fn from(err: rmp_serde::decode::Error) -> Self {
Error::MessagePack(err.to_string())
}
}
impl<T> From<tokio::sync::mpsc::error::SendError<T>> for Error {
fn from(_: tokio::sync::mpsc::error::SendError<T>) -> Self {
Error::ChannelSend
}
}
impl From<tokio::sync::oneshot::error::RecvError> for Error {
fn from(_: tokio::sync::oneshot::error::RecvError) -> Self {
Error::ChannelReceive
}
}