From cc7434a6628904d39c2455c6378db83b01332d17 Mon Sep 17 00:00:00 2001 From: Aurelien FOUCRET Date: Thu, 17 Oct 2024 09:24:29 +0200 Subject: [PATCH] Rename ParsingException into KqlParsingException --- .../org/elasticsearch/xpack/kql/parser/KqlParser.java | 2 +- .../{ParsingException.java => KqlParsingException.java} | 8 ++++---- .../elasticsearch/xpack/kql/parser/KqlParserTests.java | 9 ++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) rename x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/{ParsingException.java => KqlParsingException.java} (78%) diff --git a/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParser.java b/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParser.java index debe4f97a80f6..41bda7524c653 100644 --- a/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParser.java +++ b/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParser.java @@ -71,7 +71,7 @@ public void syntaxError( String message, RecognitionException e ) { - throw new ParsingException(message, line, charPositionInLine, e); + throw new KqlParsingException(message, line, charPositionInLine, e); } }; } diff --git a/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/ParsingException.java b/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParsingException.java similarity index 78% rename from x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/ParsingException.java rename to x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParsingException.java index f88751a551eb1..e6ac9020174f2 100644 --- a/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/ParsingException.java +++ b/x-pack/plugin/kql/src/main/java/org/elasticsearch/xpack/kql/parser/KqlParsingException.java @@ -12,24 +12,24 @@ import static org.elasticsearch.common.logging.LoggerMessageFormat.format; -public class ParsingException extends ElasticsearchException { +public class KqlParsingException extends ElasticsearchException { private final int line; private final int charPositionInLine; - public ParsingException(String message, Exception cause, int line, int charPositionInLine) { + public KqlParsingException(String message, Exception cause, int line, int charPositionInLine) { super(message, cause); this.line = line; this.charPositionInLine = charPositionInLine; } - public ParsingException(String message, int line, int charPositionInLine, Object... args) { + public KqlParsingException(String message, int line, int charPositionInLine, Object... args) { super(message, args); this.line = line; this.charPositionInLine = charPositionInLine; } - public ParsingException(String message, Throwable cause, int line, int charPositionInLine, Object... args) { + public KqlParsingException(String message, Throwable cause, int line, int charPositionInLine, Object... args) { super(message, cause, args); this.line = line; this.charPositionInLine = charPositionInLine; diff --git a/x-pack/plugin/kql/src/test/java/org/elasticsearch/xpack/kql/parser/KqlParserTests.java b/x-pack/plugin/kql/src/test/java/org/elasticsearch/xpack/kql/parser/KqlParserTests.java index a71bdfb657878..1c8b1d127e8ed 100644 --- a/x-pack/plugin/kql/src/test/java/org/elasticsearch/xpack/kql/parser/KqlParserTests.java +++ b/x-pack/plugin/kql/src/test/java/org/elasticsearch/xpack/kql/parser/KqlParserTests.java @@ -30,15 +30,18 @@ public void testSyntaxErrorsHandling() throws IOException { SearchExecutionContext searchExecutionContext = createSearchExecutionContext(); { - ParsingException e = assertThrows(ParsingException.class, () -> parser.parseKqlQuery("foo: \"bar", searchExecutionContext)); + KqlParsingException e = assertThrows( + KqlParsingException.class, + () -> parser.parseKqlQuery("foo: \"bar", searchExecutionContext) + ); assertThat(e.getLineNumber(), equalTo(1)); assertThat(e.getColumnNumber(), equalTo(6)); assertThat(e.getMessage(), equalTo("line 1:6: token recognition error at: '\"bar'")); } { - ParsingException e = assertThrows( - ParsingException.class, + KqlParsingException e = assertThrows( + KqlParsingException.class, () -> parser.parseKqlQuery("foo: (bar baz AND qux", searchExecutionContext) ); assertThat(e.getLineNumber(), equalTo(1));