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}")]
22 RecvError(RecvError), }
24
25unsafe impl Send for Error {}
26unsafe impl Sync for Error {}
27
28impl From<String> for Error {
29 fn from(v: String) -> Self {
30 Self::String(v)
31 }
32}
33
34impl From<&str> for Error {
35 fn from(v: &str) -> Self {
36 Self::String(v.to_string())
37 }
38}
39
40impl From<JsValue> for Error {
41 fn from(error: JsValue) -> Self {
42 Self::JsValue(error.into())
43 }
44}
45
46impl From<RecvError> for Error {
47 fn from(err: RecvError) -> Self {
48 Self::RecvError(err)
49 }
50}
51
52impl From<Error> for JsValue {
53 fn from(err: Error) -> Self {
54 JsValue::from_str(&err.to_string())
55 }
56}