beamer_core/
error.rs

1//! Error types for the Beamer framework.
2
3use std::fmt;
4
5/// Errors that can occur in Beamer plugins.
6#[derive(Debug)]
7pub enum PluginError {
8    /// Plugin initialization failed.
9    InitializationFailed(String),
10    /// Audio processing error.
11    ProcessingError(String),
12    /// State serialization/deserialization error.
13    StateError(String),
14    /// Editor/GUI error.
15    EditorError(String),
16    /// Platform-specific error.
17    PlatformError(String),
18    /// WebView creation or operation failed.
19    WebViewError(String),
20}
21
22impl fmt::Display for PluginError {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        match self {
25            Self::InitializationFailed(msg) => write!(f, "Initialization failed: {}", msg),
26            Self::ProcessingError(msg) => write!(f, "Processing error: {}", msg),
27            Self::StateError(msg) => write!(f, "State error: {}", msg),
28            Self::EditorError(msg) => write!(f, "Editor error: {}", msg),
29            Self::PlatformError(msg) => write!(f, "Platform error: {}", msg),
30            Self::WebViewError(msg) => write!(f, "WebView error: {}", msg),
31        }
32    }
33}
34
35impl std::error::Error for PluginError {}
36
37/// Result type for Beamer operations.
38pub type PluginResult<T> = Result<T, PluginError>;