backie/src/errors.rs

30 lines
888 B
Rust
Raw Normal View History

2023-03-04 18:07:17 +00:00
use thiserror::Error;
/// Library errors
2023-03-09 15:59:45 +00:00
#[derive(Debug, Error)]
pub enum BackieError {
2023-03-11 15:38:32 +00:00
#[error("Queue \"{0}\" needs to be configured because of registered tasks: {1:?}")]
QueueNotConfigured(String, Vec<String>),
#[error("Provided task is not serializable to JSON: {0}")]
NonSerializableTask(#[from] serde_json::Error),
#[error("Queue processing error: {0}")]
2023-03-09 15:59:45 +00:00
QueueProcessingError(#[from] AsyncQueueError),
2023-03-04 18:07:17 +00:00
#[error("Worker Pool shutdown error: {0}")]
WorkerPoolShutdownError(#[from] tokio::sync::watch::error::SendError<()>),
#[error("Worker shutdown error: {0}")]
WorkerShutdownError(#[from] tokio::sync::watch::error::RecvError),
2023-03-04 19:46:09 +00:00
}
2023-03-04 18:07:17 +00:00
#[derive(Debug, Error)]
pub enum AsyncQueueError {
#[error(transparent)]
PgError(#[from] diesel::result::Error),
#[error("Task with name {0} is not registered")]
TaskNotRegistered(String),
2023-03-04 18:07:17 +00:00
}