tauri_wasm/
error.rs

1use {
2    crate::ext,
3    std::{error, fmt},
4    wasm_bindgen::JsValue,
5};
6
7/// Common error type.
8#[derive(Debug)]
9pub struct Error(pub(crate) JsValue);
10
11impl fmt::Display for Error {
12    #[inline]
13    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14        ext::to_string(&self.0).fmt(f)
15    }
16}
17
18impl error::Error for Error {}
19
20impl From<Error> for JsValue {
21    #[inline]
22    fn from(e: Error) -> Self {
23        e.0
24    }
25}