With the Volley libraries, I extended the Request object to implement GSON serialization. I then extended that new object for how I want to do some of my PUT
requests. This is the first object for the GSON serialization:
@Override
protected Response<t> parseNetworkResponse(NetworkResponse response) {
try {
String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); //response may be too large for string?
t parsedGSON = mGson.fromJson(jsonString, cls);
Response <t> returnMessage = Response.success(parsedGSON,
HttpHeaderParser.parseIgnoreCacheHeaders(response));
return returnMessage;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return Response.error(new ParseError(e));
} catch (JsonSyntaxException je) {
je.printStackTrace();
Log.e("GsonRequest", je.getMessage()!=null?je.getMessage():"JsonSyntaxError");
return Response.error(new ParseError(je));
}
}
When my network response gets to Response <t> returnMessage = Response.success(parsedGSON, HttpHeaderParser.parseIgnoreCacheHeaders(response));
I have populated <t>
objects with the correct classes I passed in completely serialized with all variables and no errors. Yet for some reason Volley jumps to } catch (JsonSyntaxException je) {
and I can't reveal the contents of je
with debugging breakpoints or printing logs. Also in my extended class:
new ErrorListener() {
@SuppressWarnings("unused")
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
The onErrorResponse
is never called (neither is my onResponse
section either)
So now I have no idea why Volley is catching a JSONException, when serialization was successful, and I have no idea why Volley isn't returning the Error objects
Insight appreciated