Skip to main content

tauri_plugin_js/
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    #[error("process not found: {0}")]
10    ProcessNotFound(String),
11    #[error("process already exists: {0}")]
12    ProcessAlreadyExists(String),
13    #[error("process not running: {0}")]
14    ProcessNotRunning(String),
15    #[error("invalid config: {0}")]
16    InvalidConfig(String),
17    #[error("stdin write error for '{0}': {1}")]
18    StdinWriteError(String, String),
19    #[cfg(mobile)]
20    #[error(transparent)]
21    PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
22}
23
24impl Serialize for Error {
25    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
26    where
27        S: Serializer,
28    {
29        serializer.serialize_str(self.to_string().as_ref())
30    }
31}