use thiserror::Error;
use uuid::Uuid;
#[derive(Error, Debug)]
pub enum Error {
#[error("backend error: {0}")]
Backend(#[from] Box<dyn std::error::Error + Send + Sync>),
#[error("job type not registered: {0}")]
UnknownJobType(String),
#[error("job not found: {0}")]
JobNotFound(Uuid),
#[error("no runnable jobs available in queue: {0}")]
QueueEmpty(String),
#[error("lease expired for job {job_id} (worker: {worker_id})")]
LeaseExpired { job_id: Uuid, worker_id: String },
#[error("payload deserialization error: {0}")]
PayloadDeserialization(#[from] serde_json::Error),
#[error("invalid state: {0}")]
InvalidState(String),
#[error("internal queue error: {0}")]
Internal(String),
}
pub type QueueError = Error;