Skip to main content

nodedb_types/error/
details.rs

1//! Machine-matchable structured error details.
2
3use serde::{Deserialize, Serialize};
4
5/// Structured error details for programmatic matching.
6///
7/// Clients match on the variant to determine the error category, then
8/// extract structured fields. The `message` on [`crate::error::NodeDbError`]
9/// carries the human-readable explanation.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(tag = "kind", rename_all = "snake_case")]
12pub enum ErrorDetails {
13    // Write path
14    ConstraintViolation {
15        collection: String,
16    },
17    WriteConflict {
18        collection: String,
19        document_id: String,
20    },
21    DeadlineExceeded,
22    PrevalidationRejected {
23        constraint: String,
24    },
25    AppendOnlyViolation {
26        collection: String,
27    },
28    BalanceViolation {
29        collection: String,
30    },
31    PeriodLocked {
32        collection: String,
33    },
34    StateTransitionViolation {
35        collection: String,
36    },
37    TransitionCheckViolation {
38        collection: String,
39    },
40    TypeGuardViolation {
41        collection: String,
42    },
43    RetentionViolation {
44        collection: String,
45    },
46    LegalHoldActive {
47        collection: String,
48    },
49    TypeMismatch {
50        collection: String,
51    },
52    Overflow {
53        collection: String,
54    },
55    InsufficientBalance {
56        collection: String,
57    },
58    RateExceeded {
59        gate: String,
60    },
61
62    // Read path
63    CollectionNotFound {
64        collection: String,
65    },
66    DocumentNotFound {
67        collection: String,
68        document_id: String,
69    },
70    CollectionDraining {
71        collection: String,
72    },
73    CollectionDeactivated {
74        collection: String,
75        /// Wall-clock nanoseconds when retention elapses and the
76        /// collection becomes unrecoverable. Clients can render a
77        /// human-readable countdown.
78        retention_expires_at_ns: u64,
79        /// Copy-pasteable SQL the user can run to restore the
80        /// collection. Populated with the actual name, so the error
81        /// is actionable without further lookup.
82        undrop_hint: String,
83    },
84
85    // Query
86    PlanError,
87    FanOutExceeded {
88        shards_touched: u16,
89        limit: u16,
90    },
91    SqlNotEnabled,
92
93    // Auth
94    AuthorizationDenied {
95        resource: String,
96    },
97    AuthExpired,
98
99    // Sync
100    SyncConnectionFailed,
101    SyncDeltaRejected {
102        compensation: Option<crate::sync::compensation::CompensationHint>,
103    },
104    ShapeSubscriptionFailed {
105        shape_id: String,
106    },
107
108    // Storage (opaque infrastructure)
109    Storage,
110    SegmentCorrupted,
111    ColdStorage,
112    Wal,
113
114    // Serialization
115    Serialization {
116        format: String,
117    },
118    Codec,
119
120    // Config
121    Config,
122    BadRequest,
123
124    // Cluster
125    NoLeader,
126    NotLeader {
127        leader_addr: String,
128    },
129    MigrationInProgress,
130    NodeUnreachable,
131    Cluster,
132
133    // Memory
134    MemoryExhausted {
135        engine: String,
136    },
137
138    // Encryption
139    Encryption,
140
141    // Bridge / Dispatch / Internal
142    Bridge,
143    Dispatch,
144    Internal,
145}