Browse Source

Provide a constructor that captures the JSON

Rather than "debug" the JSON which does not allow further processing for the exception capture and put it inside the exception data.
pull/126/head
Archimedes Trajano 9 years ago
parent
commit
9dd0cd9fb3
  1. 24
      json-path/src/main/java/com/jayway/jsonpath/InvalidJsonException.java

24
json-path/src/main/java/com/jayway/jsonpath/InvalidJsonException.java

@ -17,18 +17,42 @@ package com.jayway.jsonpath;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class InvalidJsonException extends JsonPathException { public class InvalidJsonException extends JsonPathException {
/**
* Problematic JSON if available.
*/
private final String json;
public InvalidJsonException() { public InvalidJsonException() {
json = null;
} }
public InvalidJsonException(String message) { public InvalidJsonException(String message) {
super(message); super(message);
json = null;
} }
public InvalidJsonException(String message, Throwable cause) { public InvalidJsonException(String message, Throwable cause) {
super(message, cause); super(message, cause);
json = null;
} }
public InvalidJsonException(Throwable cause) { public InvalidJsonException(Throwable cause) {
super(cause); super(cause);
json = null;
}
/**
* Rethrow the exception with the problematic JSON captured.
*/
public InvalidJsonException(final Throwable cause, final String json) {
super(cause);
this.json = json;
}
/**
* @return the problematic JSON if available.
*/
public String getJson() {
return json;
} }
} }

Loading…
Cancel
Save