tauri_plugin_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(transparent)]
23    Fs(#[from] tauri_plugin_fs::Error),
24}
25
26impl Serialize for Error {
27    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
28    where
29        S: Serializer,
30    {
31        serializer.serialize_str(self.to_string().as_ref())
32    }
33}