Files
rustytorch/crates/specialized/rtx-neuro-db/src/error.rs
T
2026-03-04 00:08:42 +00:00

52 lines
1.3 KiB
Rust

//! Error types for database operations
use std::path::PathBuf;
use thiserror::Error;
/// Errors that can occur during database operations
#[derive(Debug, Error)]
pub enum DatabaseError {
/// SQLite error
#[error("SQLite error: {0}")]
Sqlite(#[from] rusqlite::Error),
/// Tokio-rusqlite error
#[error("Database connection error: {0}")]
Connection(#[from] tokio_rusqlite::Error),
/// I/O error
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
/// JSON serialization error
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
/// Protocol not found
#[error("Protocol not found: {id}")]
ProtocolNotFound { id: String },
/// Subject not found
#[error("Subject not found: {id}")]
SubjectNotFound { id: String },
/// Recording not found
#[error("Recording not found: {id}")]
RecordingNotFound { id: String },
/// Invalid protocol directory
#[error("Invalid protocol directory: {path}")]
InvalidProtocolDir { path: PathBuf },
/// Database not initialized
#[error("Database not initialized")]
NotInitialized,
/// Duplicate entry
#[error("Duplicate entry: {message}")]
DuplicateEntry { message: String },
}
/// Result type for database operations
pub type Result<T> = std::result::Result<T, DatabaseError>;