diff --git a/core/src/main/java/org/opensearch/sql/exception/QueryEngineException.java b/core/src/main/java/org/opensearch/sql/exception/QueryEngineException.java index b3d13bef71..122d4963fa 100644 --- a/core/src/main/java/org/opensearch/sql/exception/QueryEngineException.java +++ b/core/src/main/java/org/opensearch/sql/exception/QueryEngineException.java @@ -11,4 +11,8 @@ public class QueryEngineException extends RuntimeException { public QueryEngineException(String message) { super(message); } + + public QueryEngineException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/core/src/main/java/org/opensearch/sql/exception/SemanticCheckException.java b/core/src/main/java/org/opensearch/sql/exception/SemanticCheckException.java index 6e0c184af8..c43dfdffc8 100644 --- a/core/src/main/java/org/opensearch/sql/exception/SemanticCheckException.java +++ b/core/src/main/java/org/opensearch/sql/exception/SemanticCheckException.java @@ -7,7 +7,12 @@ /** Semantic Check Exception. */ public class SemanticCheckException extends QueryEngineException { + public SemanticCheckException(String message) { super(message); } + + public SemanticCheckException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/core/src/main/java/org/opensearch/sql/expression/ip/IPFunction.java b/core/src/main/java/org/opensearch/sql/expression/ip/IPFunction.java index 82e7778f71..8dde5e6108 100644 --- a/core/src/main/java/org/opensearch/sql/expression/ip/IPFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/ip/IPFunction.java @@ -65,9 +65,10 @@ private ExprValue exprCidrMatch(ExprValue addressExprValue, ExprValue rangeExprV try { address.validate(); } catch (AddressStringException e) { - throw new SemanticCheckException( + String msg = String.format( - "IP address '%s' is not valid. Error details: %s", addressString, e.getMessage())); + "IP address '%s' is not valid. Error details: %s", addressString, e.getMessage()); + throw new SemanticCheckException(msg, e); } // Get and validate CIDR IP address range. @@ -76,19 +77,21 @@ private ExprValue exprCidrMatch(ExprValue addressExprValue, ExprValue rangeExprV try { range.validate(); } catch (AddressStringException e) { - throw new SemanticCheckException( + String msg = String.format( "CIDR IP address range '%s' is not valid. Error details: %s", - rangeString, e.getMessage())); + rangeString, e.getMessage()); + throw new SemanticCheckException(msg, e); } // Address and range must use the same IP version (IPv4 or IPv6). if (address.isIPv4() ^ range.isIPv4()) { - throw new SemanticCheckException( + String msg = String.format( "IP address '%s' and CIDR IP address range '%s' are not compatible. Both must be" + " either IPv4 or IPv6.", - addressString, rangeString)); + addressString, rangeString); + throw new SemanticCheckException(msg); } return ExprValueUtils.booleanValue(range.contains(address)); diff --git a/docs/category.json b/docs/category.json index e90c674a2e..ca3d345e8b 100644 --- a/docs/category.json +++ b/docs/category.json @@ -28,12 +28,13 @@ "user/ppl/cmd/where.rst", "user/ppl/general/identifiers.rst", "user/ppl/general/datatypes.rst", - "user/ppl/functions/math.rst", - "user/ppl/functions/datetime.rst", - "user/ppl/functions/string.rst", "user/ppl/functions/condition.rst", + "user/ppl/functions/datetime.rst", + "user/ppl/functions/expressions.rst", + "user/ppl/functions/ip.rst", + "user/ppl/functions/math.rst", "user/ppl/functions/relevance.rst", - "user/ppl/functions/expressions.rst" + "user/ppl/functions/string.rst" ], "sql_cli": [ "user/dql/expressions.rst",