1use deadpool_sqlite::InteractError;
2
3pub type Result<T, E = Error> = std::result::Result<T, E>;
5
6#[derive(thiserror::Error, Debug)]
8pub enum Error {
9 #[error("Migration error: {0}")]
11 Migration(#[from] rusqlite_migration::Error),
12 #[error("Error opening database: {0}")]
14 OpenDatabase(eyre::Report),
15 #[error("Error acquiring database connection: {0}")]
17 PoolError(#[from] deadpool_sqlite::PoolError),
18 #[error("Database error: {0}")]
20 Database(#[from] rusqlite::Error),
21 #[error("Unexpected value type for {1}: {0}")]
23 ColumnType(#[source] rusqlite::Error, &'static str),
24 #[error("Internal error: {0}")]
26 Panic(#[from] tokio::task::JoinError),
27 #[error("Internal error: {0}")]
29 DbInteract(String),
30 #[error("Job not found")]
32 NotFound,
33 #[error("Invalid job state {0}")]
35 InvalidJobState(String),
36 #[error("Error decoding job run info {0}")]
38 InvalidJobRunInfo(serde_json::Error),
39 #[error("Error processing payload: {0}")]
41 PayloadError(serde_json::Error),
42 #[error("Timestamp {0} out of range")]
44 TimestampOutOfRange(&'static str),
45 #[error("Attempted to finish already-finished job")]
47 JobAlreadyConsumed,
48 #[error("Timed out")]
51 Timeout,
52 #[error("Job expired")]
54 Expired,
55 #[error("Worker {0} not found")]
57 WorkerNotFound(u64),
58 #[error("Queue closed unexpectedly")]
60 QueueClosed,
61}
62
63impl From<InteractError> for Error {
64 fn from(e: InteractError) -> Self {
65 Error::DbInteract(e.to_string())
66 }
67}
68
69impl Error {
70 pub(crate) fn open_database(err: impl Into<eyre::Report>) -> Self {
71 Error::OpenDatabase(err.into())
72 }
73}