Skip to main content

agentic_time/
error.rs

1//! Error types for AgenticTime.
2
3use thiserror::Error;
4
5/// Errors that can occur in temporal operations.
6#[derive(Error, Debug)]
7pub enum TimeError {
8    /// Entity not found by ID.
9    #[error("Temporal entity not found: {0}")]
10    NotFound(String),
11
12    /// Invalid time range (start after end).
13    #[error("Invalid time range: start {start} is after end {end}")]
14    InvalidRange {
15        /// Range start.
16        start: String,
17        /// Range end.
18        end: String,
19    },
20
21    /// Deadline has already passed.
22    #[error("Deadline already passed: {0}")]
23    DeadlinePassed(String),
24
25    /// Schedule conflict detected.
26    #[error("Schedule conflict: {0} overlaps with {1}")]
27    ScheduleConflict(String, String),
28
29    /// Sequence dependency not met.
30    #[error("Sequence dependency not met: step {step} depends on {dependency}")]
31    DependencyNotMet {
32        /// The step that cannot proceed.
33        step: String,
34        /// The unmet dependency.
35        dependency: String,
36    },
37
38    /// Invalid recurrence pattern.
39    #[error("Invalid recurrence pattern: {0}")]
40    InvalidRecurrence(String),
41
42    /// Invalid duration (e.g. negative).
43    #[error("Invalid duration: {0}")]
44    InvalidDuration(String),
45
46    /// File format error.
47    #[error("File format error: {0}")]
48    FileFormat(String),
49
50    /// IO error.
51    #[error("IO error: {0}")]
52    Io(#[from] std::io::Error),
53
54    /// Serialization error.
55    #[error("Serialization error: {0}")]
56    Serialization(#[from] serde_json::Error),
57}
58
59/// Result type alias for temporal operations.
60pub type TimeResult<T> = Result<T, TimeError>;