From adf0c389c5c284b12f3fae9e19870650f1b99b7a Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 15 Jun 2021 17:22:04 +0200 Subject: [PATCH] Rename FilterParsing into InvalidFilter --- milli/src/error.rs | 4 ++-- milli/src/search/facet/filter_condition.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/milli/src/error.rs b/milli/src/error.rs index 294b2aa57..78a1b1c59 100644 --- a/milli/src/error.rs +++ b/milli/src/error.rs @@ -53,7 +53,7 @@ pub enum UserError { Csv(csv::Error), MaxDatabaseSizeReached, DocumentLimitReached, - FilterParsing(pest::error::Error), + InvalidFilter(pest::error::Error), InvalidCriterionName { name: String }, InvalidDocumentId { document_id: Value }, InvalidFilterAttribute(pest::error::Error), @@ -199,7 +199,7 @@ impl fmt::Display for UserError { Self::AttributeLimitReached => f.write_str("maximum number of attributes reached"), Self::Csv(error) => error.fmt(f), Self::DocumentLimitReached => f.write_str("maximum number of documents reached"), - Self::FilterParsing(error) => error.fmt(f), + Self::InvalidFilter(error) => error.fmt(f), Self::InvalidCriterionName { name } => write!(f, "invalid criterion {}", name), Self::InvalidDocumentId { document_id } => { let json = serde_json::to_string(document_id).unwrap(); diff --git a/milli/src/search/facet/filter_condition.rs b/milli/src/search/facet/filter_condition.rs index 6d99bb977..424118f77 100644 --- a/milli/src/search/facet/filter_condition.rs +++ b/milli/src/search/facet/filter_condition.rs @@ -110,7 +110,7 @@ impl FilterCondition { { let fields_ids_map = index.fields_ids_map(rtxn)?; let filterable_fields = index.filterable_fields_ids(rtxn)?; - let lexed = FilterParser::parse(Rule::prgm, expression).map_err(UserError::FilterParsing)?; + let lexed = FilterParser::parse(Rule::prgm, expression).map_err(UserError::InvalidFilter)?; FilterCondition::from_pairs(&fields_ids_map, &filterable_fields, lexed) } @@ -169,8 +169,8 @@ impl FilterCondition { let (lresult, _) = pest_parse(items.next().unwrap()); let (rresult, _) = pest_parse(items.next().unwrap()); - let lvalue = lresult.map_err(UserError::FilterParsing)?; - let rvalue = rresult.map_err(UserError::FilterParsing)?; + let lvalue = lresult.map_err(UserError::InvalidFilter)?; + let rvalue = rresult.map_err(UserError::InvalidFilter)?; Ok(Operator(fid, Between(lvalue, rvalue))) } @@ -204,7 +204,7 @@ impl FilterCondition { let value = items.next().unwrap(); let (result, _svalue) = pest_parse(value); - let value = result.map_err(UserError::FilterParsing)?; + let value = result.map_err(UserError::InvalidFilter)?; Ok(Operator(fid, GreaterThan(value))) } @@ -221,7 +221,7 @@ impl FilterCondition { let value = items.next().unwrap(); let (result, _svalue) = pest_parse(value); - let value = result.map_err(UserError::FilterParsing)?; + let value = result.map_err(UserError::InvalidFilter)?; Ok(Operator(fid, GreaterThanOrEqual(value))) } @@ -238,7 +238,7 @@ impl FilterCondition { let value = items.next().unwrap(); let (result, _svalue) = pest_parse(value); - let value = result.map_err(UserError::FilterParsing)?; + let value = result.map_err(UserError::InvalidFilter)?; Ok(Operator(fid, LowerThan(value))) } @@ -255,7 +255,7 @@ impl FilterCondition { let value = items.next().unwrap(); let (result, _svalue) = pest_parse(value); - let value = result.map_err(UserError::FilterParsing)?; + let value = result.map_err(UserError::InvalidFilter)?; Ok(Operator(fid, LowerThanOrEqual(value))) }