1use crate::types::TxId;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5 #[error("table not found: {0}")]
6 TableNotFound(String),
7 #[error("{0} are immutable")]
8 ImmutableTable(String),
9 #[error("invalid state transition: {0}")]
10 InvalidStateTransition(String),
11 #[error("propagation aborted: {table}.{column} transition {from} -> {to} is invalid")]
12 PropagationAborted {
13 table: String,
14 column: String,
15 from: String,
16 to: String,
17 },
18 #[error("BFS depth exceeds maximum allowed ({0})")]
19 BfsDepthExceeded(u32),
20 #[error("BFS visited set exceeded limit ({0})")]
21 BfsVisitedExceeded(usize),
22 #[error("dimension mismatch: expected {expected}, got {got}")]
23 VectorDimensionMismatch { expected: usize, got: usize },
24 #[error("not found: {0}")]
25 NotFound(String),
26 #[error("transaction not found: {0}")]
27 TxNotFound(TxId),
28 #[error("unique constraint violation: {table}.{column}")]
29 UniqueViolation { table: String, column: String },
30 #[error("foreign key violation: {table}.{column} references {ref_table}")]
31 ForeignKeyViolation {
32 table: String,
33 column: String,
34 ref_table: String,
35 },
36 #[error("recursive CTEs are not supported")]
37 RecursiveCteNotSupported,
38 #[error("window functions are not supported")]
39 WindowFunctionNotSupported,
40 #[error("stored procedures/functions are not supported")]
41 StoredProcNotSupported,
42 #[error("graph traversal requires explicit depth bound")]
43 UnboundedTraversal,
44 #[error("vector search requires LIMIT clause")]
45 UnboundedVectorSearch,
46 #[error("subqueries not supported; use CTE chaining")]
47 SubqueryNotSupported,
48 #[error("full-text search (WHERE column MATCH) is not supported")]
49 FullTextSearchNotSupported,
50 #[error("parse error: {0}")]
51 ParseError(String),
52 #[error("plan error: {0}")]
53 PlanError(String),
54 #[error("sync error: {0}")]
55 SyncError(String),
56 #[error("table {0} is not sync-eligible (no natural key)")]
57 NotSyncEligible(String),
58 #[error(
59 "cycle detected: inserting {edge_type} edge from {source_node} to {target_node} would create a cycle"
60 )]
61 CycleDetected {
62 edge_type: String,
63 source_node: uuid::Uuid,
64 target_node: uuid::Uuid,
65 },
66 #[error("plugin rejected at {hook}: {reason}")]
67 PluginRejected { hook: String, reason: String },
68 #[error(
69 "memory budget exceeded: {subsystem}/{operation} requested {requested_bytes} bytes, {available_bytes} available of {budget_limit_bytes} budget. Hint: {hint}"
70 )]
71 MemoryBudgetExceeded {
72 subsystem: String,
73 operation: String,
74 requested_bytes: usize,
75 available_bytes: usize,
76 budget_limit_bytes: usize,
77 hint: String,
78 },
79 #[error(
80 "disk budget exceeded: {operation} - file is {current_bytes} bytes, limit is {budget_limit_bytes} bytes. Hint: {hint}"
81 )]
82 DiskBudgetExceeded {
83 operation: String,
84 current_bytes: u64,
85 budget_limit_bytes: u64,
86 hint: String,
87 },
88 #[error("{0}")]
89 Other(String),
90}
91
92pub type Result<T> = std::result::Result<T, Error>;