Skip to main content

apalis_postgres/
error.rs

1use apalis_core::task::{status::StatusError, task_id::TaskIdError};
2use sqlx::Error as SqlxError;
3/// Represents a wrapper for errors encountered on this crate
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// Inner engine error
7    #[error(transparent)]
8    Database(#[from] SqlxError),
9    /// Error handling json
10    #[error("JsonError: {0}")]
11    JsonError(serde_json::Error),
12    /// Reenqueue Mismatch error
13    #[error("ReenqueueMismatch: Queued [{queued}] , Abandoned[{abandoned}] ")]
14    ReenqueueMismatch {
15        /// The db count
16        queued: usize,
17        /// The workers count
18        abandoned: usize,
19    },
20    /// Error decoding the task_id
21    #[error("TaskIdError: {0}")]
22    TaskIdError(TaskIdError),
23    /// Error decoding the task status
24    #[error("StatusError: {0}")]
25    StatusError(StatusError),
26    /// Worker was removed in the database
27    #[error("WorkerOutOfSync")]
28    WorkerOutOfSync,
29
30    /// Tried to register a worker that already exists
31    #[error("WorkerAlreadyExists: {0}")]
32    WorkerAlreadyExists(String),
33}