navree_queue/error.rs
1//! [`QueueError`].
2
3use navree_db::DbError;
4use navree_orm::OrmError;
5
6/// What can go wrong when queueing or working jobs.
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum QueueError {
10 /// No module registered a handler for the job type (`m.job::<J>()`).
11 #[error(
12 "no handler is registered for job type `{job_type}`; register it with `m.job::<J>()` (ModuleBuilderJobsExt)"
13 )]
14 UnknownJob {
15 /// The job type ([`Job::NAME`](navree_contracts::Job::NAME)).
16 job_type: String,
17 },
18 /// `retry` was given the id of a failed job that does not exist.
19 #[error("there is no failed job with id `{id}`")]
20 FailedJobNotFound {
21 /// The id given.
22 id: String,
23 },
24 /// The job could not be serialized, or a stored job could not be read back.
25 #[error("invalid job payload: {0}")]
26 Payload(#[source] serde_json::Error),
27 /// A database error (database driver).
28 #[error(transparent)]
29 Db(#[from] DbError),
30 /// A failed-jobs ORM operation failed (database driver).
31 #[error(transparent)]
32 Orm(#[from] OrmError),
33 /// A driver from another crate failed (a [`QueueStore`](crate::QueueStore)
34 /// such as navree-redis's): connection, protocol, ...
35 #[error("the queue driver failed: {0}")]
36 Store(navree_contracts::BoxError),
37 /// The app owning the queue has been dropped.
38 #[error("the app owning this queue has shut down")]
39 ShutDown,
40 /// Operations are stored in the app database, and the app has no
41 /// `DatabaseModule`.
42 #[error("operations need the app database: add DatabaseModule to the app")]
43 NoDatabase,
44}