Skip to content

Commit

Permalink
Repo::sendRequestAsync(): capture all kinds of Guzzle exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed Feb 14, 2023
1 parent 8ba2259 commit ca4c118
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/acdhOeaw/arche/lib/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\RejectedPromise;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -338,7 +339,7 @@ public function sendRequestAsync(Request $request): ResponsePromise {
$request = $request->withHeader($this->getHeaderName('transactionId'), $this->txId);
}
$promise = $this->client->sendAsync($request)->otherwise(
function (RequestException $e) {
function (TransferException $e) {
switch ($e->getCode()) {
case 410:
return new RejectedPromise(new Deleted());
Expand All @@ -364,7 +365,7 @@ function (RequestException $e) {
* signature `f(mixed $iterElement, Repo $thisRepoObject): GuzzleHttp\Promise\PromiseInterface`.
* @param int $concurrency number of promises executed in parallel
* @param int $rejectAction what to do with rejected promises - one of
* Repo::REJECT_SKIP (skip the silently), Repo::REJECT_FAIL (throw an error)
* Repo::REJECT_SKIP (skip them silently), Repo::REJECT_FAIL (throw an error)
* and Repo::REJECT_INCLUDE (include the rejection value in the results).
* @return array<mixed>
*/
Expand Down

0 comments on commit ca4c118

Please sign in to comment.