Return an error when calling DELETE /tasks with an empty query

This commit is contained in:
Loïc Lecrenier 2022-10-15 11:17:06 +02:00 committed by Clément Renault
parent fbd2be2ec8
commit f32b973945
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
4 changed files with 28 additions and 1 deletions

View file

@ -15,7 +15,9 @@ pub enum Error {
CorruptedTaskQueue,
#[error("Task `{0}` not found")]
TaskNotFound(TaskId),
// TODO: Lo: proper error message for this
#[error("Cannot delete all tasks")]
TaskDeletionWithEmptyQuery,
// maybe the two next errors are going to move to the frontend
#[error("`{0}` is not a status. Available status are")]
InvalidStatus(String),
@ -41,6 +43,7 @@ impl ErrorCode for Error {
Error::IndexNotFound(_) => Code::IndexNotFound,
Error::IndexAlreadyExists(_) => Code::IndexAlreadyExists,
Error::TaskNotFound(_) => Code::TaskNotFound,
Error::TaskDeletionWithEmptyQuery => Code::TaskDeletionWithEmptyQuery,
Error::InvalidStatus(_) => Code::BadRequest,
Error::InvalidKind(_) => Code::BadRequest,