Skip to main content

lattice_common/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum LatticeError {
5    #[error("Allocation not found: {0}")]
6    AllocationNotFound(String),
7
8    #[error("Node not found: {0}")]
9    NodeNotFound(String),
10
11    #[error("Tenant not found: {0}")]
12    TenantNotFound(String),
13
14    #[error("VCluster not found: {0}")]
15    VClusterNotFound(String),
16
17    #[error("Resource constraint violation: {0}")]
18    ResourceConstraint(String),
19
20    #[error("Topology constraint violation: {0}")]
21    TopologyConstraint(String),
22
23    #[error("Quota exceeded for tenant {tenant}: {detail}")]
24    QuotaExceeded { tenant: String, detail: String },
25
26    #[error("Sensitive isolation violation: {0}")]
27    SensitiveIsolation(String),
28
29    #[error("Node ownership conflict: node {node} already owned by {owner}")]
30    OwnershipConflict { node: String, owner: String },
31
32    #[error("Dependency not satisfied: {0}")]
33    DependencyNotSatisfied(String),
34
35    #[error("Authentication failed: {0}")]
36    AuthenticationFailed(String),
37
38    #[error("Authorization denied: {0}")]
39    AuthorizationDenied(String),
40
41    #[error("Quorum error: {0}")]
42    QuorumError(String),
43
44    #[error("Configuration error: {0}")]
45    ConfigError(String),
46
47    #[error("Storage error: {0}")]
48    StorageError(String),
49
50    #[error("Internal error: {0}")]
51    Internal(String),
52
53    // ─── Observability errors ───────────────────────────────
54    #[error("Cannot attach to allocation {allocation}: state is {state}, expected Running")]
55    AttachNotRunning { allocation: String, state: String },
56
57    #[error("Attach denied: user {user} is not authorized to attach to allocation {allocation}")]
58    AttachDenied { user: String, allocation: String },
59
60    #[error("Logs not available for allocation {allocation}")]
61    LogsNotAvailable { allocation: String },
62
63    #[error("Metrics query failed: {0}")]
64    MetricsQueryFailed(String),
65
66    #[error("Diagnostics not available for allocation {allocation}: allocation must be in Running state")]
67    DiagnosticsNotAvailable { allocation: String },
68
69    #[error("Comparison failed: {0}")]
70    CompareFailed(String),
71}