Skip to main content

yarli_cli/yarli-queue/src/
error.rs

1//! Error types for yarli-queue.
2
3use thiserror::Error;
4use uuid::Uuid;
5
6/// Errors from task queue operations.
7#[derive(Debug, Error)]
8pub enum QueueError {
9    /// Entry not found in the queue.
10    #[error("queue entry not found: {0}")]
11    NotFound(Uuid),
12
13    /// Entry is not in the expected status for this operation.
14    #[error("invalid status for {entry_id}: expected {expected}, got {actual}")]
15    InvalidStatus {
16        entry_id: Uuid,
17        expected: &'static str,
18        actual: String,
19    },
20
21    /// Lease has expired and was reclaimed.
22    #[error("lease expired for entry {0}")]
23    LeaseExpired(Uuid),
24
25    /// Lease owner mismatch — another worker holds the lease.
26    #[error("lease owner mismatch for entry {entry_id}: expected {expected}, got {actual}")]
27    LeaseOwnerMismatch {
28        entry_id: Uuid,
29        expected: String,
30        actual: String,
31    },
32
33    /// Duplicate task_id already in queue for this run.
34    #[error("duplicate task in queue: task_id={0}")]
35    DuplicateTask(Uuid),
36
37    /// Concurrency cap exceeded.
38    #[error("concurrency cap exceeded: {0}")]
39    ConcurrencyCapExceeded(String),
40
41    /// Database operation failed.
42    #[error("database error: {0}")]
43    Database(String),
44
45    /// Tokio runtime operation failed.
46    #[error("runtime error: {0}")]
47    Runtime(String),
48
49    /// Persisted queue status is invalid.
50    #[error("invalid queue status in store: {0}")]
51    InvalidQueueStatus(String),
52
53    /// Persisted command class is invalid.
54    #[error("invalid command class in store: {0}")]
55    InvalidCommandClass(String),
56}