Skip to content

Commit

Permalink
chore(Core): move retry delay to ServiceException (#5955)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwarajanand committed Mar 13, 2023
1 parent 35e403c commit 68aca6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
19 changes: 0 additions & 19 deletions Core/src/Exception/AbortedException.php
Expand Up @@ -22,24 +22,5 @@
*/
class AbortedException extends ServiceException
{
/**
* Return the delay in seconds and nanos before retrying the failed request.
*
* @return array
*/
public function getRetryDelay()
{
$metadata = array_filter($this->metadata, function ($metadataItem) {
return array_key_exists('retryDelay', $metadataItem);
});

if (count($metadata) === 0) {
return ['seconds' => 0, 'nanos' => 0];
}

return $metadata[0]['retryDelay'] + [
'seconds' => 0,
'nanos' => 0
];
}
}
20 changes: 20 additions & 0 deletions Core/src/Exception/ServiceException.php
Expand Up @@ -153,6 +153,26 @@ public function getReason()
return $this->errorReason;
}

/**
* Return the delay in seconds and nanos before retrying the failed request.
*
* @return array
*/
public function getRetryDelay()
{
$metadata = array_filter($this->metadata, function ($metadataItem) {
return array_key_exists('retryDelay', $metadataItem);
});

if (count($metadata) === 0) {
return ['seconds' => 0, 'nanos' => 0];
}

return $metadata[0]['retryDelay'] + [
'seconds' => 0,
'nanos' => 0
];
}

/**
* Helper to return the error info from an exception
Expand Down

0 comments on commit 68aca6c

Please sign in to comment.