From 68aca6c4935e67f2f4879269a49eb37a5a39a30a Mon Sep 17 00:00:00 2001 From: Vishwaraj Anand Date: Mon, 13 Mar 2023 21:31:24 +0530 Subject: [PATCH] chore(Core): move retry delay to ServiceException (#5955) --- Core/src/Exception/AbortedException.php | 19 ------------------- Core/src/Exception/ServiceException.php | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Core/src/Exception/AbortedException.php b/Core/src/Exception/AbortedException.php index 208c4303f3e..91d284ea633 100644 --- a/Core/src/Exception/AbortedException.php +++ b/Core/src/Exception/AbortedException.php @@ -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 - ]; - } } diff --git a/Core/src/Exception/ServiceException.php b/Core/src/Exception/ServiceException.php index 843205369a3..fd2a438b858 100644 --- a/Core/src/Exception/ServiceException.php +++ b/Core/src/Exception/ServiceException.php @@ -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