use std::fmt;
#[derive(Debug)]
pub struct SetupError(Box<dyn std::error::Error>);
impl From<Box<dyn std::error::Error>> for SetupError {
fn from(error: Box<dyn std::error::Error>) -> Self {
Self(error)
}
}
unsafe impl Send for SetupError {}
unsafe impl Sync for SetupError {}
impl fmt::Display for SetupError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl std::error::Error for SetupError {}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("runtime error: {0}")]
Runtime(#[from] tauri_runtime::Error),
#[error("a window with label `{0}` already exists")]
WindowLabelAlreadyExists(String),
#[error("asset not found: {0}")]
AssetNotFound(String),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("{0}")]
Io(#[from] std::io::Error),
#[error("invalid icon: {0}")]
InvalidIcon(std::io::Error),
#[error("invalid args `{1}` for command `{0}`: {2}")]
InvalidArgs(&'static str, &'static str, serde_json::Error),
#[error("error encountered during setup hook: {0}")]
Setup(SetupError),
#[error("failed to initialize plugin `{0}`: {1}")]
PluginInitialization(String, String),
#[error("invalid url: {0}")]
InvalidUrl(url::ParseError),
#[error(transparent)]
JoinError(#[from] tokio::task::JoinError),
#[cfg(feature = "isolation")]
#[error("isolation pattern error: {0}")]
IsolationPattern(#[from] tauri_utils::pattern::isolation::Error),
#[error("invalid window url: {0}")]
InvalidWindowUrl(&'static str),
#[error("invalid glob pattern: {0}")]
GlobPattern(#[from] glob::PatternError),
#[cfg(feature = "icon-png")]
#[error("failed to decode PNG: {0}")]
PngDecode(#[from] png::DecodingError),
#[error("Unexpected `raw_window_handle` for the current platform")]
InvalidWindowHandle,
#[cfg(target_os = "android")]
#[error("jni error: {0}")]
Jni(#[from] jni::errors::Error),
#[error("failed to receive message")]
FailedToReceiveMessage,
#[error("menu error: {0}")]
#[cfg(desktop)]
Menu(#[from] muda::Error),
#[error(transparent)]
#[cfg(desktop)]
BadMenuIcon(#[from] muda::BadIcon),
#[error("tray icon error: {0}")]
#[cfg(all(desktop, feature = "tray-icon"))]
#[cfg_attr(docsrs, doc(cfg(all(desktop, feature = "tray-icon"))))]
Tray(#[from] tray_icon::Error),
#[error(transparent)]
#[cfg(all(desktop, feature = "tray-icon"))]
#[cfg_attr(docsrs, doc(cfg(all(desktop, feature = "tray-icon"))))]
BadTrayIcon(#[from] tray_icon::BadIcon),
#[error("path does not have a parent")]
NoParent,
#[error("path does not have an extension")]
NoExtension,
#[error("path does not have a basename")]
NoBasename,
#[error("failed to read current dir: {0}")]
CurrentDir(std::io::Error),
#[cfg(not(target_os = "android"))]
#[error("unknown path")]
UnknownPath,
#[cfg(target_os = "android")]
#[error(transparent)]
PluginInvoke(#[from] crate::plugin::mobile::PluginInvokeError),
#[error("window not found")]
WindowNotFound,
#[error("The resource id {0} is invalid.")]
BadResourceId(crate::resources::ResourceId),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
}
pub type Result<T> = std::result::Result<T, Error>;