Interface EvaluationError
- All Known Implementing Classes:
EvaluationError.ExtensionResultMismatch, EvaluationError.IntegerOutOfRange, EvaluationError.NodelistTooLarge, EvaluationError.QueryTooDeep, EvaluationError.RegexTooComplex, EvaluationError.SignatureMismatch, EvaluationError.UnknownFunction
public sealed interface EvaluationError
permits EvaluationError.UnknownFunction, EvaluationError.SignatureMismatch, EvaluationError.IntegerOutOfRange, EvaluationError.QueryTooDeep, EvaluationError.NodelistTooLarge, EvaluationError.RegexTooComplex, EvaluationError.ExtensionResultMismatch
The reason why the evaluator cannot give a correct result.
A query that selects nothing is not an error: the result is an empty nodelist. An error occurs only when the evaluator cannot give the correct nodelist.
| Error | Cause | Query from the parser |
|---|---|---|
EvaluationError.NodelistTooLarge |
a nodelist has more nodes than JsonPathEvaluator.Limits.maxNodes() |
can occur |
EvaluationError.RegexTooComplex |
a regular expression of match() or search() is too large |
can occur |
EvaluationError.UnknownFunction |
the evaluator has no implementation for a function | no |
EvaluationError.SignatureMismatch |
a call does not agree with the signature of its function | no |
EvaluationError.IntegerOutOfRange |
an index or a slice parameter is outside the I-JSON range | no |
EvaluationError.QueryTooDeep |
the query has more than JsonPathEvaluator.MAX_QUERY_DEPTH nested expressions |
no |
EvaluationError.ExtensionResultMismatch |
a function extension gives an instance of the wrong type | can occur |
The first two errors are the overflow indications of RFC 9535, Section 2.1.
JsonPathEvaluator strict = JsonPathEvaluator.standard()
.withLimits(new JsonPathEvaluator.Limits(5, 1_000)); // at most 5 nodes in a nodelist
String outcome = switch (strict.evaluate(query("$[*]"), root, JacksonJsonModel.INSTANCE)) {
case Result.Ok(List<Node<JsonNode>> nodes) -> nodes.size() + " nodes";
case Result.Err(EvaluationError.NodelistTooLarge(int limit)) -> "more than " + limit + " nodes";
case Result.Err(EvaluationError.RegexTooComplex(String pattern, int limit)) -> "regexp too large: " + pattern;
case Result.Err(EvaluationError error) -> error.message();
};
// outcome: "more than 5 nodes"
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA function extension returned an instance of the wrong type.static final recordAn index or a slice parameter is outside the I-JSON range.static final recordOverflow indication: a nodelist has more nodes than the limit (RFC 9535, Section 2.1).static final recordThe query has more nested expressions thanJsonPathEvaluator.MAX_QUERY_DEPTH.static final recordOverflow indication: a regular expression of match() or search() is valid, but too complex to evaluate in the resource limits (RFC 9485, Section 8).static final recordA function call has a result type, a number of arguments, or argument types that do not agree with the signature of the function.static final recordThe query calls a function that the evaluator does not have. -
Method Summary
-
Method Details
-
message
-