1use thiserror::Error;
5use wasm_bindgen::JsValue;
6use workflow_core::channel::RecvError;
7use workflow_wasm::jserror::*;
9
10#[derive(Error, Debug, Clone)]
12pub enum Error {
13 #[error("{0}")]
15 String(String),
16 #[error("{0}")]
20 JsValue(JsErrorData),
21 #[error("{0}")]
23 RecvError(RecvError), }
25
26unsafe impl Send for Error {}
27unsafe impl Sync for Error {}
28
29impl From<String> for Error {
30 fn from(v: String) -> Self {
31 Self::String(v)
32 }
33}
34
35impl From<&str> for Error {
36 fn from(v: &str) -> Self {
37 Self::String(v.to_string())
38 }
39}
40
41impl From<JsValue> for Error {
42 fn from(error: JsValue) -> Self {
43 Self::JsValue(error.into())
44 }
45}
46
47impl From<RecvError> for Error {
48 fn from(err: RecvError) -> Self {
49 Self::RecvError(err)
50 }
51}
52
53impl From<Error> for JsValue {
54 fn from(err: Error) -> Self {
55 JsValue::from_str(&err.to_string())
56 }
57}