use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum UniError {
#[error("Database not found: {path}")]
NotFound { path: PathBuf },
#[error("Schema error: {message}")]
Schema { message: String },
#[error("Parse error: {message}")]
Parse {
message: String,
position: Option<usize>,
line: Option<usize>,
column: Option<usize>,
context: Option<String>,
},
#[error("Query error: {message}")]
Query {
message: String,
query: Option<String>,
},
#[error("Transaction error: {message}")]
Transaction { message: String },
#[error("Transaction conflict: {message}")]
TransactionConflict { message: String },
#[error("Transaction already completed")]
TransactionAlreadyCompleted,
#[error("Operation '{operation}' not supported on read-only database")]
ReadOnly { operation: String },
#[error("Label '{label}' not found in schema")]
LabelNotFound { label: String },
#[error("Edge type '{edge_type}' not found in schema")]
EdgeTypeNotFound { edge_type: String },
#[error("Property '{property}' not found on {entity_type} with label '{label}'")]
PropertyNotFound {
property: String,
entity_type: String, label: String,
},
#[error("Index '{index}' not found")]
IndexNotFound { index: String },
#[error("Snapshot '{snapshot_id}' not found")]
SnapshotNotFound { snapshot_id: String },
#[error("Query exceeded memory limit of {limit_bytes} bytes")]
MemoryLimitExceeded { limit_bytes: usize },
#[error("Database is locked by another process")]
DatabaseLocked,
#[error("Operation timed out after {timeout_ms}ms")]
Timeout { timeout_ms: u64 },
#[error("Type error: expected {expected}, got {actual}")]
Type { expected: String, actual: String },
#[error("Constraint violation: {message}")]
Constraint { message: String },
#[error("Storage error: {message}")]
Storage {
message: String,
#[source]
source: Option<Box<dyn std::error::Error + Send + Sync>>,
},
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Internal error: {0}")]
Internal(#[from] anyhow::Error),
#[error("Invalid identifier '{name}': {reason}")]
InvalidIdentifier { name: String, reason: String },
#[error("Label '{label}' already exists")]
LabelAlreadyExists { label: String },
#[error("Edge type '{edge_type}' already exists")]
EdgeTypeAlreadyExists { edge_type: String },
#[error("Permission denied: {action}")]
PermissionDenied { action: String },
#[error("Argument '{arg}' is invalid: {message}")]
InvalidArgument { arg: String, message: String },
#[error("A write context is already active on session '{session_id}'")]
WriteContextAlreadyActive {
session_id: String,
hint: &'static str,
},
#[error("Transaction '{tx_id}' commit timed out")]
CommitTimeout { tx_id: String, hint: &'static str },
#[error("Transaction '{tx_id}' expired")]
TransactionExpired { tx_id: String, hint: &'static str },
#[error("Operation cancelled")]
Cancelled,
#[error("Derived facts are stale: version gap is {version_gap}")]
StaleDerivedFacts { version_gap: u64 },
#[error("Rule conflict: rule '{rule_name}' conflicts during promotion")]
RuleConflict { rule_name: String },
#[error("Hook rejected: {message}")]
HookRejected { message: String },
}
pub type Result<T> = std::result::Result<T, UniError>;