@@ -10,7 +10,7 @@ built on top of [ReactPHP](https://reactphp.org/).
1010Let's say you crawl a page and find that you need to send 100 HTTP requests to
1111following pages which each takes ` 0.2s ` . You can either send them all
1212sequentially (taking around ` 20s ` ) or you can use
13- [ ReactPHP] ( https://reactphp.org ) to concurrently request all your pages at the
13+ [ ReactPHP] ( https://reactphp.org/ ) to concurrently request all your pages at the
1414same time. This works perfectly fine for a small number of operations, but
1515sending an excessive number of requests can either take up all resources on your
1616side or may get you banned by the remote side as it sees an unreasonable number
@@ -84,12 +84,14 @@ $q = new Clue\React\Mq\Queue(3, null, function ($url) use ($browser) {
8484foreach ($urls as $url) {
8585 $q($url)->then(function (Psr\Http\Message\ResponseInterface $response) use ($url) {
8686 echo $url . ': ' . $response->getBody()->getSize() . ' bytes' . PHP_EOL;
87+ }, function (Exception $e) {
88+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
8789 });
8890}
8991
9092```
9193
92- See also the [ examples] ( examples ) .
94+ See also the [ examples] ( examples/ ) .
9395
9496## Usage
9597
@@ -292,6 +294,8 @@ $promise = Queue::all(3, $urls, function ($url) use ($browser) {
292294
293295$promise->then(function (array $responses) {
294296 echo 'All ' . count($responses) . ' successful!' . PHP_EOL;
297+ }, function (Exception $e) {
298+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
295299});
296300```
297301
@@ -368,6 +372,8 @@ $promise = Queue::any(3, $urls, function ($url) use ($browser) {
368372
369373$promise->then(function (ResponseInterface $response) {
370374 echo 'First response: ' . $response->getBody() . PHP_EOL;
375+ }, function (Exception $e) {
376+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
371377});
372378```
373379
0 commit comments