wick_invocation_server/
error.rs

1use thiserror::Error;
2
3/// The RPC Error type.
4#[derive(Error, Debug)]
5#[non_exhaustive]
6pub enum Error {
7  /// Error during the parsing of an IP address and port.
8  #[error(transparent)]
9  AddrParseError(#[from] std::net::AddrParseError),
10
11  /// Upstream error from Tonic.
12  #[error(transparent)]
13  TranportFailure(#[from] tonic::transport::Error),
14
15  /// Upstream error from [wick_rpc].
16  #[error(transparent)]
17  RpcError(#[from] wick_rpc::Error),
18
19  /// Internal Error.
20  #[error("Internal Error: {0}")]
21  InternalError(String),
22
23  /// Error used by collections.
24  #[error("{0}")]
25  CollectionError(String),
26
27  /// Error generated by a collection's components.
28  #[error("Component error: {0}")]
29  ComponentError(String),
30
31  /// Error sending output to channel.
32  #[error("Error sending output to channel")]
33  SendError,
34
35  /// General Error.
36  #[error("General error: {0}")]
37  Other(String),
38}
39
40impl From<tokio::task::JoinError> for Error {
41  fn from(e: tokio::task::JoinError) -> Self {
42    Error::InternalError(format!("Tokio Error: {}", e))
43  }
44}
45
46impl From<std::io::Error> for Error {
47  fn from(e: std::io::Error) -> Self {
48    Error::InternalError(format!("IO Error: {}", e))
49  }
50}
51
52impl From<Box<dyn std::error::Error + Send + Sync>> for Error {
53  fn from(e: Box<dyn std::error::Error + Send + Sync>) -> Self {
54    Error::CollectionError(e.to_string())
55  }
56}