1use workflow_core::channel::ChannelError;
4use thiserror::Error;
7use workflow_nw::ipc::ResponseError;
8
9#[derive(Debug, Error)]
10pub enum Error {
11 #[error("{0}")]
12 Custom(String),
13
14 #[error("platform is not supported")]
15 Platform,
16
17 #[error("Channel error")]
18 ChannelError(String),
19
20 #[error(transparent)]
21 Store(#[from] workflow_store::error::Error),
22
23 #[error(transparent)]
24 NodeJs(#[from] workflow_node::error::Error),
25
26 #[error(transparent)]
27 Ipc(#[from] workflow_nw::ipc::error::Error),
28}
29
30impl Error {
31 pub fn custom<T: Into<String>>(msg: T) -> Self {
32 Error::Custom(msg.into())
33 }
34}
35
36impl<T> From<ChannelError<T>> for Error {
37 fn from(e: ChannelError<T>) -> Error {
38 Error::ChannelError(e.to_string())
39 }
40}
41
42impl From<String> for Error {
43 fn from(err: String) -> Self {
44 Self::Custom(err)
45 }
46}
47
48impl From<&str> for Error {
49 fn from(err: &str) -> Self {
50 Self::Custom(err.to_string())
51 }
52}
53
54impl From<Error> for ResponseError {
55 fn from(e: Error) -> Self {
56 ResponseError::Custom(e.to_string())
57 }
58}