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))) }