1use slim_auth::errors::AuthError;
5use thiserror::Error;
6
7#[cfg(feature = "session")]
8use slim_session::errors::SessionError as SessionErrorType;
9
10#[cfg(feature = "session")]
11pub use slim_session::subscription_manager::SubscriptionAckError;
12
13#[derive(Error, Debug)]
14pub enum ServiceError {
15 #[error("no server or client configured")]
17 NoServerOrClientConfigured,
18 #[cfg(not(target_arch = "wasm32"))]
19 #[error("grpc configuration error")]
20 ConfigError(#[from] slim_config::errors::ConfigError),
21 #[error("invalid configuration: {0}")]
22 InvalidConfig(String),
23 #[cfg(not(target_arch = "wasm32"))]
24 #[error("id error")]
25 IdError(#[from] slim_config::component::id::IdError),
26
27 #[error("application name missing")]
29 NoAppName,
30 #[error("identity provider missing")]
31 NoIdentityProvider,
32 #[error("identity verifier missing")]
33 NoIdentityVerifier,
34 #[error("app already registered")]
35 AppAlreadyRegistered,
36 #[error("app not found: {0}")]
37 AppNotFound(String),
38
39 #[error("provider auth error")]
41 ProviderAuthError(#[from] AuthError),
42
43 #[error("connection error: {0}")]
45 ConnectionError(String),
46 #[error("disconnect error: {0}")]
47 DisconnectError(String),
48 #[error("client already connected: {0}")]
49 ClientAlreadyConnected(String),
50 #[error("server not found: {0}")]
51 ServerNotFound(String),
52 #[error("connection not found: {0}")]
53 ConnectionNotFoundForEndpoint(String),
54 #[error("different id found for connection {endpoint}: expected {expected}, found {found}")]
55 DifferentIdForConnection {
56 endpoint: String,
57 expected: u64,
58 found: u64,
59 },
60
61 #[cfg(feature = "session")]
63 #[error("error sending subscription")]
64 SubscriptionError(#[source] SubscriptionAckError),
65 #[cfg(feature = "session")]
66 #[error("error sending unsubscription")]
67 UnsubscriptionError(#[source] SubscriptionAckError),
68 #[error("error on set route: {0}")]
69 SetRouteError(String),
70 #[error("error on remove route: {0}")]
71 RemoveRouteError(String),
72
73 #[error("error publishing message: {0}")]
75 PublishError(String),
76 #[error("receive timeout waiting for item")]
78 ReceiveTimeout,
79 #[error("receive channel closed")]
80 ReceiveChannelClosed,
81 #[error("message decode failure: {0}")]
82 ReceiveDecodeFailure(String),
83 #[error("error sending message: {0}")]
84 MessageSendingError(String),
85
86 #[cfg(feature = "session")]
88 #[error("session not found")]
89 SessionNotFound,
90 #[cfg(feature = "session")]
91 #[error("to be able to call invite/remove, session must be multicast: {0}")]
92 SessionMustBeMulticast(String),
93 #[cfg(feature = "session")]
94 #[error("error in session")]
95 SessionError(Box<SessionErrorType>),
96
97 #[cfg(not(target_arch = "wasm32"))]
99 #[error("controller error")]
100 Controller(#[from] slim_controller::errors::ControllerError),
101 #[error("datapath error")]
102 DataPath(#[from] slim_datapath::errors::DataPathError),
103
104 #[error("storage error: {0}")]
106 StorageError(String), #[error("storage I/O error")]
108 StorageIo(#[from] std::io::Error),
109 #[error("storage home directory unavailable")]
110 HomeDirUnavailable,
111
112 #[error("drain signal missing")]
114 NoDrainSignal,
115 #[error("timed out while waiting for sessions to close")]
116 DrainTimeoutError,
117
118 #[error("unknown error")]
120 Unknown,
121}
122
123#[cfg(feature = "session")]
124impl From<SessionErrorType> for ServiceError {
125 fn from(err: SessionErrorType) -> Self {
126 ServiceError::SessionError(Box::new(err))
127 }
128}