tauri_plugin_haptics/
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// TODO: Improve Error handling (different typed errors instead of one (stringified) PluginInvokeError for all mobile errors)
10
11#[derive(Debug, thiserror::Error)]
12#[cfg_attr(feature = "specta", derive(specta::Type))]
13pub enum Error {
14    #[cfg(mobile)]
15    #[error(transparent)]
16    PluginInvoke(
17        #[cfg_attr(feature = "specta", serde(skip))]
18        #[from]
19        tauri::plugin::mobile::PluginInvokeError,
20    ),
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}