From 131fe309347a6c2694373ddab388310a28bc20db Mon Sep 17 00:00:00 2001 From: Irevoire Date: Fri, 21 Oct 2022 14:12:25 +0200 Subject: [PATCH] fix the error messages and the index stats --- index-scheduler/src/error.rs | 17 +++++------------ meilisearch-http/src/routes/indexes/mod.rs | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/index-scheduler/src/error.rs b/index-scheduler/src/error.rs index 1db0d2786..a4e94c663 100644 --- a/index-scheduler/src/error.rs +++ b/index-scheduler/src/error.rs @@ -6,25 +6,20 @@ use crate::TaskId; #[derive(Error, Debug)] pub enum Error { - #[error("Index `{0}` not found")] + #[error("Index `{0}` not found.")] IndexNotFound(String), - #[error("Index `{0}` already exists")] + #[error("Index `{0}` already exists.")] IndexAlreadyExists(String), #[error("Corrupted task queue.")] CorruptedTaskQueue, #[error("Corrupted dump.")] CorruptedDump, - #[error("Task `{0}` not found")] + #[error("Task `{0}` not found.")] TaskNotFound(TaskId), - #[error("Query parameters to filter the tasks to delete are missing. Available query parameters are: `uid`, `indexUid`, `status`, `type`")] + #[error("Query parameters to filter the tasks to delete are missing. Available query parameters are: `uid`, `indexUid`, `status`, `type`.")] TaskDeletionWithEmptyQuery, - #[error("Query parameters to filter the tasks to cancel are missing. Available query parameters are: `uid`, `indexUid`, `status`, `type`")] + #[error("Query parameters to filter the tasks to cancel are missing. Available query parameters are: `uid`, `indexUid`, `status`, `type`.")] TaskCancelationWithEmptyQuery, - // maybe the two next errors are going to move to the frontend - #[error("`{0}` is not a status. Available status are")] - InvalidStatus(String), - #[error("`{0}` is not a type. Available types are")] - InvalidKind(String), #[error(transparent)] Dump(#[from] dump::Error), @@ -49,8 +44,6 @@ impl ErrorCode for Error { Error::TaskNotFound(_) => Code::TaskNotFound, Error::TaskDeletionWithEmptyQuery => Code::TaskDeletionWithEmptyQuery, Error::TaskCancelationWithEmptyQuery => Code::TaskCancelationWithEmptyQuery, - Error::InvalidStatus(_) => Code::BadRequest, - Error::InvalidKind(_) => Code::BadRequest, Error::Dump(e) => e.error_code(), Error::Milli(e) => e.error_code(), diff --git a/meilisearch-http/src/routes/indexes/mod.rs b/meilisearch-http/src/routes/indexes/mod.rs index 81d6fdd44..b86e6b4bc 100644 --- a/meilisearch-http/src/routes/indexes/mod.rs +++ b/meilisearch-http/src/routes/indexes/mod.rs @@ -180,7 +180,7 @@ pub async fn get_index_stats( ) -> Result { analytics.publish("Stats Seen".to_string(), json!({ "per_index_uid": true }), Some(&req)); - let stats = IndexStats::new((*index_scheduler).clone(), index_uid.into_inner()); + let stats = IndexStats::new((*index_scheduler).clone(), index_uid.into_inner())?; debug!("returns: {:?}", stats); Ok(HttpResponse::Ok().json(stats))