Skip to main content

tauri_plugin_gpui/
error.rs

1/// Errors returned by the plugin's public API.
2#[derive(Debug, thiserror::Error)]
3#[non_exhaustive]
4pub enum GpuiError {
5    /// [`crate::init`] has not been called (or failed) for this application.
6    #[error("tauri-plugin-gpui is not initialized; call `tauri_plugin_gpui::init(app)` in `setup`")]
7    NotInitialized,
8
9    /// [`crate::init`] was called more than once.
10    #[error("tauri-plugin-gpui is already initialized")]
11    AlreadyInitialized,
12
13    /// GPUI is already attached to this window. Attachment is permanent.
14    #[error("GPUI is already attached to window `{label}`")]
15    AlreadyAttached {
16        /// Label of the Tauri window.
17        label: String,
18    },
19
20    /// The window cannot host a GPUI surface (for example it already hosts a WebView).
21    #[error("window `{label}` is not eligible for GPUI attachment: {reason}")]
22    NotEligible {
23        /// Label of the Tauri window.
24        label: String,
25        /// Why the window cannot be attached.
26        reason: &'static str,
27    },
28
29    /// The call must happen on the Tauri/TAO event-loop thread.
30    #[error("must be called on the Tauri event-loop (main) thread")]
31    NotMainThread,
32
33    /// The shared GPUI `App` is already borrowed further up the stack.
34    #[error("the shared GPUI App is already in use further up the call stack")]
35    Reentrant,
36
37    /// The operation is outside the minimal GPUI platform adapter.
38    #[error("unsupported operation: {operation}")]
39    UnsupportedOperation {
40        /// Name of the unsupported operation.
41        operation: &'static str,
42    },
43
44    /// The GPUI platform adapter could not be created.
45    #[error("GPUI platform initialization failed: {0}")]
46    PlatformInitialization(String),
47
48    /// The GPU renderer for a window could not be created.
49    #[error("GPUI renderer initialization failed: {0}")]
50    RendererInitialization(String),
51
52    /// An error reported by Tauri while querying the window.
53    #[error(transparent)]
54    Tauri(#[from] tauri::Error),
55}