use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
Enqueue(#[from] EnqueueError),
#[error(transparent)]
Perform(#[from] PerformError),
#[error(transparent)]
Fetch(#[from] FetchError),
#[error("error getting connection to db {0}")]
SQL(#[from] sqlx::Error),
#[error("Couldn't spawn onto executor {0}")]
Spawn(#[from] futures::task::SpawnError),
#[error("Migrations could not be run {0}")]
Migrate(#[from] sqlx::migrate::MigrateError),
}
#[derive(Debug, Error)]
pub enum FetchError {
#[error("Got no response from worker")]
NoMessage,
#[error("Timeout reached while waiting for worker to finish")]
Timeout,
#[error("Couldn't load job from storage {0}")]
FailedLoadingJob(#[from] sqlx::Error),
}
#[derive(Debug, Error)]
pub enum EnqueueError {
#[error("Error inserting task {0}")]
Sql(#[from] sqlx::Error),
#[error("Error encoding task for insertion {0}")]
Encode(#[from] serde_json::Error),
#[error("Error enqueuing batch tasks")]
Batch(#[from] BatchInsertError),
}
#[derive(Debug, Error)]
pub enum BatchInsertError {
#[error("Error converting between integer and ascii")]
Itoa(#[from] std::fmt::Error),
#[error("Error inserting task {0}")]
Sql(#[from] sqlx::Error),
}
pub type PerformError = Box<dyn std::error::Error + Send + Sync>;
#[doc(hidden)]
#[cfg(any(test, feature = "test_components"))]
#[derive(Debug, PartialEq)]
pub enum FailedJobsError {
JobsFailed(
i64,
),
}