tauri_plugin_liquid_glass/
error.rs

1use serde::{Serialize, Serializer};
2
3/// Error types for the liquid-glass plugin
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// The operation is not supported on this platform
7    #[error("Not supported on this platform")]
8    UnsupportedPlatform,
9
10    /// The macOS version is not supported
11    #[error("macOS version is not supported (requires 26+)")]
12    UnsupportedMacOSVersion,
13
14    /// The specified window was not found
15    #[error("Window not found: {0}")]
16    WindowNotFound(String),
17
18    /// Failed to create glass effect view
19    #[error("Failed to create glass effect view")]
20    ViewCreationFailed,
21
22    /// Failed to acquire registry lock
23    #[error("Failed to acquire glass view registry lock")]
24    RegistryLockFailed,
25
26    /// Invalid color format
27    #[error("Invalid color format: {0}")]
28    InvalidColorFormat(String),
29
30    /// Tauri error
31    #[error("Tauri error: {0}")]
32    Tauri(#[from] tauri::Error),
33}
34
35// Make error serializable for JavaScript
36impl Serialize for Error {
37    fn serialize<S: Serializer>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> {
38        serializer.serialize_str(&self.to_string())
39    }
40}
41
42/// Result type for the liquid-glass plugin
43pub type Result<T> = std::result::Result<T, Error>;