From 7476ad659927fb7d43ca10fc3b489148c05ca6b2 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 9 Apr 2024 12:02:07 +0200 Subject: [PATCH] Add error codes --- meilisearch-types/src/error.rs | 1 + meilisearch/src/error.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/meilisearch-types/src/error.rs b/meilisearch-types/src/error.rs index eea012331..6777a7ebe 100644 --- a/meilisearch-types/src/error.rs +++ b/meilisearch-types/src/error.rs @@ -245,6 +245,7 @@ InvalidSearchCropMarker , InvalidRequest , BAD_REQUEST ; InvalidSearchFacets , InvalidRequest , BAD_REQUEST ; InvalidSearchSemanticRatio , InvalidRequest , BAD_REQUEST ; InvalidFacetSearchFacetName , InvalidRequest , BAD_REQUEST ; +InvalidRecommendId , InvalidRequest , BAD_REQUEST ; InvalidSearchFilter , InvalidRequest , BAD_REQUEST ; InvalidSearchHighlightPostTag , InvalidRequest , BAD_REQUEST ; InvalidSearchHighlightPreTag , InvalidRequest , BAD_REQUEST ; diff --git a/meilisearch/src/error.rs b/meilisearch/src/error.rs index 5a0b04020..13e460c24 100644 --- a/meilisearch/src/error.rs +++ b/meilisearch/src/error.rs @@ -23,6 +23,8 @@ pub enum MeilisearchHttpError { InvalidContentType(String, Vec), #[error("Document `{0}` not found.")] DocumentNotFound(String), + #[error("Document `{0}` not found.")] + InvalidDocumentId(String), #[error("Sending an empty filter is forbidden.")] EmptyFilter, #[error("Invalid syntax for the filter parameter: `expected {}, found: {1}`.", .0.join(", "))] @@ -70,6 +72,7 @@ impl ErrorCode for MeilisearchHttpError { MeilisearchHttpError::MissingPayload(_) => Code::MissingPayload, MeilisearchHttpError::InvalidContentType(_, _) => Code::InvalidContentType, MeilisearchHttpError::DocumentNotFound(_) => Code::DocumentNotFound, + MeilisearchHttpError::InvalidDocumentId(_) => Code::InvalidDocumentId, MeilisearchHttpError::EmptyFilter => Code::InvalidDocumentFilter, MeilisearchHttpError::InvalidExpression(_, _) => Code::InvalidSearchFilter, MeilisearchHttpError::PayloadTooLarge(_) => Code::PayloadTooLarge,