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