tauri_plugin_typegen/
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
13    #[error("Command analysis failed: {0}")]
14    CommandAnalysis(String),
15
16    #[error("Code generation failed: {0}")]
17    CodeGeneration(String),
18
19    #[error("Invalid project path: {0}")]
20    InvalidProjectPath(String),
21}
22
23impl Serialize for Error {
24    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
25    where
26        S: Serializer,
27    {
28        serializer.serialize_str(self.to_string().as_ref())
29    }
30}