Interface EvaluationError

All Known Implementing Classes:
EvaluationError.ExtensionResultMismatch, EvaluationError.IntegerOutOfRange, EvaluationError.NodelistTooLarge, EvaluationError.QueryTooDeep, EvaluationError.RegexTooComplex, EvaluationError.SignatureMismatch, EvaluationError.UnknownFunction

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"
  • Method Details

    • message

      default String message()
      Returns a description of the error.
      Returns:
      a description of the error