There is a json, contains String value for parameter, e.g. status and this json maps by Gson on POJO, and this parameter maps on custom enum.
JSON:
{"status":"on"}
POJO
public class StatusData {
@SerializedName("status")
@Expose
private Status status;
}
enum:
public enum Status {
@SerializedName("on")ON,
@SerializedName("off")OFF;
}
And if json contains correct values ("on" or "off") - all right, but if there is unsupported value e.g. "unknown" - then it crushes with Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference. And question: is there way to change message of exception for understanding what went wrong?