Skip to main content

tauri_plugin_system_components/
error.rs

1use serde::{ser::Serializer, Serialize};
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7    #[error(transparent)]
8    Io(#[from] std::io::Error),
9    #[cfg(mobile)]
10    #[error(transparent)]
11    PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
12    /// The command exists but has no implementation on this platform.
13    /// The JS API documents this rejection as the platform-detection
14    /// contract: tab-bar commands reject on desktop, window-glass
15    /// commands reject on iOS.
16    #[error("unsupported on this platform: {0}")]
17    Unsupported(&'static str),
18    #[error("{0}")]
19    WindowHandle(String),
20}
21
22impl Serialize for Error {
23    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
24    where
25        S: Serializer,
26    {
27        serializer.serialize_str(self.to_string().as_ref())
28    }
29}