Skip to content

Commit 22b0ad3

Browse files
committed
Retrying API calls on transfer exceptions
1 parent b8ed371 commit 22b0ad3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/php/class-api-client.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Sgdg\Vendor\Google\Service\Drive\FileList;
2727
use Sgdg\Vendor\Google\Service\Exception as Google_Service_Exception;
2828
use Sgdg\Vendor\Google\Task\Runner;
29+
use Sgdg\Vendor\GuzzleHttp\Exception\TransferException;
2930
use Sgdg\Vendor\GuzzleHttp\Promise\Promise;
3031
use Sgdg\Vendor\GuzzleHttp\Promise\PromiseInterface;
3132
use Sgdg\Vendor\GuzzleHttp\Promise\Utils;
@@ -321,7 +322,12 @@ private static function execute_current_batch() {
321322
),
322323
'Batch Drive call',
323324
static function () use ( $batch ) {
324-
$ret = $batch->execute();
325+
try {
326+
$ret = $batch->execute();
327+
} catch ( TransferException $e ) {
328+
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
329+
throw new Google_Service_Exception( $e->getMessage() );
330+
}
325331

326332
foreach ( $ret as $response ) {
327333
$exception = self::wrap_response_exception( $response );

0 commit comments

Comments
 (0)