You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the RequestFuture I realized that I can not handle network errors because doing future.get() forces me to implement ExecutionException, InterruptedException and TimeoutException.
By controlling the RequestFuture of the source code, I realized that the onRespoceError method as VolleyError parameter that would be perfect to know the type of network failure by VolleyError.NetworkResponse.
Instead, what is done is a throw new ExecutionException(mException) and then I can not have the VolleyError.NetworkResponse.
Since RequestFuture implements the standard Java Future interface, get() has to throw an ExecutionException. Not an oversight, but an intentional design choice to be interoperable with Future.
It's not perfectly clean, but the safe thing to do is:
try {
...
} catch (ExecutionException e) {
if (e.getCause() instanceof VolleyError) {
VolleyError volleyError = (VolleyError) e.getCause();
// Handle the VolleyError
}
// Handle other errors
}
It's actually guaranteed by the current implementation that e.getCause() can only be a VolleyError, so you could skip the getCause() check and other error handling as they're actually impossible, but this would be relying on a Volley implementation detail so I would suggest the instanceof check for safety's sake.
Using the RequestFuture I realized that I can not handle network errors because doing future.get() forces me to implement ExecutionException, InterruptedException and TimeoutException.
By controlling the RequestFuture of the source code, I realized that the onRespoceError method as VolleyError parameter that would be perfect to know the type of network failure by VolleyError.NetworkResponse.
Instead, what is done is a throw new ExecutionException(mException) and then I can not have the VolleyError.NetworkResponse.
I'm doing something wrong, or it was an oversight during the development of the future?
Thank you
The text was updated successfully, but these errors were encountered: