I'm using Volley to make synchronous requests to a server. The following is how I'd make a synchronous request --
RequestFuture<JSONObject> future = RequestFuture.newFuture();
JsonObjectRequest request = new JsonObjectRequest("http://my-url.com", future, future);
requestQueue.add(request);
try {
JSONObject response = future.get();
} catch (InterruptedException e) {
} catch (ExecutionException e) {
// Handle exceptions.
}
There are various reasons that this could fail - server errors, timeouts, malformed url exceptions, etc and I'm wondering if there is a way for me to determine the specific cause of failure. It looks like ExecutionException wraps all of the various exceptions that could be thrown, but I'd rather not have a bunch of executionException.getCause() instanceOf FooException
calls to determine the failure reason. Is there a cleaner way to determine the cause of failure?