From 2a32ad39a09b8848d485577379e4c8a2cec4cdc5 Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 27 May 2020 17:43:37 +0200 Subject: [PATCH] move filter parse error display to core --- meilisearch-core/src/error.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meilisearch-core/src/error.rs b/meilisearch-core/src/error.rs index de0391bce..62840c2a8 100644 --- a/meilisearch-core/src/error.rs +++ b/meilisearch-core/src/error.rs @@ -160,6 +160,20 @@ impl fmt::Display for Error { impl error::Error for Error {} +struct FilterParseError(PestError); + +impl fmt::Display for FilterParseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use crate::pest_error::LineColLocation::*; + + let (line, column) = match self.0.line_col { + Span((line, _), (column, _)) => (line, column), + Pos((line, column)) => (line, column), + }; + write!(f, "parsing error on line {} at column {}: {}", line, column, self.0.variant.message()) + } +} + #[derive(Debug)] pub enum FacetError { EmptyArray,