1

How about exception handling in volley, does it provide exception handling mechanism in build or we need to handle it separately?

Vishwanath.M
  • 6,235
  • 11
  • 42
  • 56

1 Answers1

3

when you create a request object in Volley you need to specify an error listener, Volley invokes the onErrorResponse callback method of that listener passing an instance of the VolleyError object when there is an error while performing the request.

The following is the list of exceptions in Volley:

AuthFailureError — If you are trying to do Http Basic authentication then this error is most likely to come.

NetworkError — Socket disconnection, server down, DNS issues might result in this error.

NoConnectionError — Similar to NetworkError, but fires when the device does not have Internet connection, your error handling logic can club NetworkError and NoConnectionError together and treat them similarly.

ParseError — While using JsonObjectRequest or JsonArrayRequest if the received JSON is malformed then this exception will be generated. If you get this error then it is a problem that should be fixed instead of being handled.

ServerError — The server responded with an error, most likely with 4xx or 5xx HTTP status codes.

TimeoutError — Socket timeout, either server is too busy to handle the request or there is some network latency issue. By default, Volley times out the request after 2.5 seconds, use a RetryPolicy if you are consistently getting this error.

Source: http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using-volley/

mrtpk
  • 1,398
  • 4
  • 18
  • 38
Sathish
  • 1,147
  • 3
  • 10
  • 20