Files
clustri/src-tauri/src/error.rs
T

57 lines
1.2 KiB
Rust
Raw Normal View History

2026-07-29 13:47:45 +00:00
use serde::{Serialize, Serializer};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Connection not found: {0}")]
ConnectionNotFound(String),
2026-07-29 13:47:45 +00:00
#[error("Not connected to server")]
NotConnected,
2026-07-29 13:47:45 +00:00
#[error("HTTP request failed: {0}")]
HttpError(#[from] reqwest::Error),
#[error("Cannot connect to server: {0}")]
ConnectionFailed(String),
2026-07-29 13:47:45 +00:00
#[error("Certificate error: {0}")]
CertificateError(String),
#[error("Invalid credentials: {0}")]
InvalidCredentials(String),
2026-07-29 13:47:45 +00:00
#[error("Authentication failed: {0}")]
AuthError(String),
2026-07-29 13:47:45 +00:00
#[error("Keyring error: {0}")]
KeyringError(String),
2026-07-29 13:47:45 +00:00
#[error("Serialization error: {0}")]
SerializationError(String),
2026-07-29 13:47:45 +00:00
#[error("Invalid URL: {0}")]
InvalidUrl(String),
2026-07-29 13:47:45 +00:00
#[error("API error: {0}")]
ApiError(String),
#[error("WebSocket error: {0}")]
WebSocketError(String),
#[error("Tauri error: {0}")]
TauriError(#[from] tauri::Error),
#[error("I/O error: {0}")]
IoError(#[from] std::io::Error),
2026-07-29 13:47:45 +00:00
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}