Skip to main content

journal_engine/
error.rs

1//! Error types for journal engine operations
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Errors that can occur during engine operations
7#[derive(Debug, Error)]
8pub enum EngineError {
9    /// I/O error when reading files
10    #[error("I/O error: {0}")]
11    Io(#[from] std::io::Error),
12
13    /// Error from journal core operations
14    #[error("Journal error: {0}")]
15    Journal(#[from] journal_core::JournalError),
16
17    /// Error from journal indexing operations
18    #[error("Index error: {0}")]
19    Index(#[from] journal_index::IndexError),
20
21    /// Error from repository operations
22    #[error("Repository error: {0}")]
23    Repository(#[from] journal_registry::repository::RepositoryError),
24
25    /// Error from registry operations
26    #[error("Registry error: {0}")]
27    Registry(#[from] journal_registry::RegistryError),
28
29    /// Error when parsing a journal file path
30    #[error("Failed to parse journal file path: {path}")]
31    InvalidPath { path: String },
32
33    /// Error when a path contains invalid UTF-8
34    #[error("Path contains invalid UTF-8: {}", .path.display())]
35    InvalidUtf8 { path: PathBuf },
36
37    /// Channel closed error
38    #[error("Channel closed")]
39    ChannelClosed,
40
41    /// Foyer cache error
42    #[error("Cache error: {0}")]
43    Foyer(#[from] foyer::Error),
44
45    /// Foyer IO engine error
46    #[error("Foyer IO error: {0}")]
47    FoyerIo(#[from] foyer::IoError),
48
49    /// Operation was cancelled
50    #[error("Operation cancelled")]
51    Cancelled,
52
53    /// Invalid time range (start >= end)
54    #[error("Invalid time range: start={start} >= end={end}")]
55    InvalidTimeRange { start: u32, end: u32 },
56}
57
58static_assertions::const_assert!(std::mem::size_of::<EngineError>() <= 64);
59
60/// A specialized Result type for engine operations
61pub type Result<T> = std::result::Result<T, EngineError>;