Skip to main content

azums_core/
error.rs

1use thiserror::Error;
2use uuid::Uuid;
3
4/// Primary error enum for `azums` job queue operations.
5#[derive(Error, Debug)]
6pub enum Error {
7    /// Storage backend error wrapper.
8    #[error("backend error: {0}")]
9    Backend(#[from] Box<dyn std::error::Error + Send + Sync>),
10
11    /// Job type has no registered handler.
12    #[error("job type not registered: {0}")]
13    UnknownJobType(String),
14
15    /// Job with specified ID was not found.
16    #[error("job not found: {0}")]
17    JobNotFound(Uuid),
18
19    /// Queue is empty or no jobs are ready for leasing.
20    #[error("no runnable jobs available in queue: {0}")]
21    QueueEmpty(String),
22
23    /// Lease expired for specified job and worker.
24    #[error("lease expired for job {job_id} (worker: {worker_id})")]
25    LeaseExpired { job_id: Uuid, worker_id: String },
26
27    /// JSON payload deserialization failure.
28    #[error("payload deserialization error: {0}")]
29    PayloadDeserialization(#[from] serde_json::Error),
30
31    /// Invalid configuration or state transition error.
32    #[error("invalid state: {0}")]
33    InvalidState(String),
34
35    /// General internal error.
36    #[error("internal queue error: {0}")]
37    Internal(String),
38}
39
40/// Type alias for backward compatibility.
41pub type QueueError = Error;