appcore_gateway/error.rs
1// =============================================================================
2// #######
3// ### ### F: error.rs
4// ## ## ## ## P: AppCore-Runtime
5// ## ##
6// C: 2026/07/26 08:53:09 by dnettoRaw
7// ## ## ## ## U: 2026/07/26 08:53:09 by dnettoRaw
8// ########### S: 1.0.1-rc.8
9// =============================================================================
10
11//! Gateway-scoped error types.
12
13use appcore_types::RuntimeError;
14
15/// Failures produced during Gateway operation.
16#[derive(Debug, thiserror::Error)]
17pub enum GatewayError {
18 /// A configuration validation or parsing failure.
19 #[error("configuration error: {0}")]
20 Config(String),
21
22 /// Missing or cryptographically invalid token credentials.
23 #[error("authentication failed: {0}")]
24 Authentication(String),
25
26 /// Valid credentials but unauthorized for the target resource.
27 #[error("authorization failed: {0}")]
28 Forbidden(String),
29
30 /// Multi-tenant boundary checks failed.
31 #[error("tenant mismatch: {0}")]
32 TenantMismatch(String),
33
34 /// No active worker is registered to serve the requested capability.
35 #[error("worker unavailable for capability: {0}")]
36 WorkerUnavailable(String),
37
38 /// Underlying WebSocket connection transport failed.
39 #[error("transport error: {0}")]
40 Transport(String),
41
42 /// JSON serialization or deserialization failed.
43 #[error("serialization error: {0}")]
44 Serialization(String),
45
46 /// Protocol or envelope structure violation.
47 #[error("protocol violation: {0}")]
48 Protocol(String),
49
50 /// Inner AppCore runtime error.
51 #[error("runtime core error: {0:?}")]
52 Runtime(RuntimeError),
53}
54
55impl From<RuntimeError> for GatewayError {
56 fn from(err: RuntimeError) -> Self {
57 GatewayError::Runtime(err)
58 }
59}
60
61/// Specialized Result type for Gateway operations.
62pub type GatewayResult<T> = Result<T, GatewayError>;