我正在寻找一种方法来获取抛出的VolleyError的响应代码.我的ErrorListener看起来像这样:
Response.ErrorListener errorListener = new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { error.printStackTrace(); //Get response code here VolleyLog.e("Error: ",error.toString()); VolleyLog.e("Error: ",error.getLocalizedMessage()); } };
我发送到我的VolleyLog的2行打印如下:
03-12 10:57:56.932: E/Volley(7147): [1] 1.onErrorResponse: Error: 03-12 10:57:56.932: E/Volley(7147): [1] 1.onErrorResponse: Error:
Volley确实知道回来了,因为我也可以在我的VolleyLog中看到以下内容:
03-12 10:57:56.692: E/Volley(7147): [41854] BasicNetwork.performRequest: Unexpected response code 403 for https://*******/Employee/authenticate 03-12 10:57:56.897: E/Volley(7147): [41854] BasicNetwork.performRequest: Unexpected response code 403 for https://*******/Employee/authenticate 03-12 10:57:56.902: W/System.err(7147): com.android.volley.AuthFailureError 03-12 10:57:56.902: W/System.err(7147): at com.android.volley.toolBox.BasicNetwork.performRequest(BasicNetwork.java:143) 03-12 10:57:56.902: W/System.err(7147): at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)