1use std::path::PathBuf;
6
7use serde::{Serialize, Serializer};
8
9#[derive(Debug, thiserror::Error)]
11#[non_exhaustive]
12pub enum Error {
13 #[error(transparent)]
15 Json(#[from] serde_json::Error),
16 #[error(transparent)]
18 Tauri(#[from] tauri::Error),
19 #[error(transparent)]
21 Io(#[from] std::io::Error),
22 #[error("forbidden path: {0}")]
24 PathForbidden(PathBuf),
25 #[error("invalid glob pattern: {0}")]
27 GlobPattern(#[from] glob::PatternError),
28 #[cfg(feature = "watch")]
30 #[error(transparent)]
31 Watch(#[from] notify::Error),
32 #[cfg(target_os = "android")]
34 #[error(transparent)]
35 PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
36 #[error("URL is not a valid path")]
38 InvalidPathUrl,
39 #[error("Unsafe PathBuf: {0}")]
41 UnsafePathBuf(&'static str),
42}
43
44impl Serialize for Error {
45 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
46 where
47 S: Serializer,
48 {
49 serializer.serialize_str(self.to_string().as_ref())
50 }
51}