tauri_plugin_advanced_file_manager/dialog/
error.rs

1// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5use serde::{ser::Serializer, Serialize};
6
7pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum Error {
12    #[error(transparent)]
13    Tauri(#[from] tauri::Error),
14    #[error(transparent)]
15    Io(#[from] std::io::Error),
16    #[cfg(mobile)]
17    #[error(transparent)]
18    PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
19    #[cfg(mobile)]
20    #[error("Folder picker is not implemented on mobile")]
21    FolderPickerNotImplemented,
22    // 使用主模块的 Error
23    #[error(transparent)]
24    Fs(#[from] crate::Error),
25}
26
27impl Serialize for Error {
28    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
29    where
30        S: Serializer,
31    {
32        serializer.serialize_str(self.to_string().as_ref())
33    }
34}