i Have 2 responses in my api response one for success if the data is correct and one for incorrect data i can't handle it with my pojo class and this is my class
public class AirCraftSearchResponse {
@SerializedName("Data")
@Expose
private Data data;
@SerializedName("Message")
@Expose
private Object message;
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public Object getMessage() {
return message;
}
public void setMessage(Object message) {
this.message = message;
}
and this is the two responses of faill
{
"Success": false,
"Message": "Could not convert string to DateTime: 2019-12-08T0000:00. Path 'Legs[0].DateTime', line 1, position 1185.",
"Data": [],
"total": 0
}
and success response is
{
"Success": true,
"Message": "",
"Data": {},
"total": 0
}
when i make response and i get success there is no problem happen because my pojo class have same object for response and when i get fail it make exception and i can't handle or get it's message because it goes to onFailure method when i print it's message i get this line
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 143 path $.Data