Batch request function - Manage response / request relationship

23 views
Skip to first unread message

Matt J

unread,
Nov 18, 2014, 5:51:06 PM11/18/14
to guz...@googlegroups.com

I have been trying to use the batch feature to download a number of image resources. I need to understand which requests have had a good response (so that they can be processed further) and which have failed (for error logging).

I have read extensively on guide (Though rather slim on detail):

Plus forums:

This solution looks interesting but uses SendAll() which i have seen no reference to in Guzzle 4 docs?

The functions getSuccessful() and getFailures() look interesting but provide no way to identify which request each response is from

If i use the following on a bad result:
try{
        $result2 = $results->getResult($requests[1]);
        echo "Result2: " . $result2->getStatusCode();
    } catch(Exception $e){
            if($e->getMessage()){
                    $error = $e->getMessage();
            } else {
                    $error = 'Generic exception caught';
            }
        
            echo "Error: $error";
    }

I get an error that isnt caught, plus the above doesnt feel like a good way to manage the success/fail process.

Is there a recommended pattern for this?

Matt





Reply all
Reply to author
Forward
0 new messages