Browse Source

Merge pull request #134 from trajano/value-compare-exception-ctor

Alternate constructor for ValueCompareException
pull/135/head
kallestenflo 9 years ago
parent
commit
1a6c34021e
  1. 3
      json-path/src/main/java/com/jayway/jsonpath/Criteria.java
  2. 10
      json-path/src/main/java/com/jayway/jsonpath/ValueCompareException.java

3
json-path/src/main/java/com/jayway/jsonpath/Criteria.java

@ -912,8 +912,7 @@ public class Criteria implements Predicate {
JsonValue json = (JsonValue) left;
return right.equals(json.parsed(ctx)) ? 0 : -1;
} else {
logger.debug("Can not compare a {} with a {}", left.getClass().getName(), right.getClass().getName());
throw new ValueCompareException();
throw new ValueCompareException(left, right);
}
}

10
json-path/src/main/java/com/jayway/jsonpath/ValueCompareException.java

@ -19,6 +19,16 @@ public class ValueCompareException extends JsonPathException {
public ValueCompareException() {
}
/**
* Construct the exception with message capturing the classes for two objects.
*
* @param left first object
* @param right second object
*/
public ValueCompareException(final Object left, final Object right) {
super(String.format("Can not compare a %1s with a %2s", left.getClass().getName(), right.getClass().getName()));
}
public ValueCompareException(String message) {
super(message);
}

Loading…
Cancel
Save