Core/src/RetryDeciderTrait.php
private function getRetryFunction($shouldRetryMessages = true)
    {
        $httpRetryCodes = $this->httpRetryCodes;
        $httpRetryMessages = $this->httpRetryMessages;

        return function (\Exception $ex) use ($httpRetryCodes, $httpRetryMessages, $shouldRetryMessages) {
            $statusCode = $ex->getCode();

            if (in_array($statusCode, $httpRetryCodes)) {
                return true;
            }

            if (!$shouldRetryMessages) {
                return false;
            }

            $message = ($ex instanceof RequestException && $ex->hasResponse())
                ? (string) $ex->getResponse()->getBody()
                : $ex->getMessage();

            try {
                $message = $this->jsonDecode(
                    $message,
                    true
                );
            } catch (\InvalidArgumentException $ex) {
                return false;
            }

            if (!isset($message['error']['errors'])) {
                return false;
            }

            foreach ($message['error']['errors'] as $error) {
                if (in_array($error['reason'], $httpRetryMessages)) {
                    return true;
                }
            }

            return false;
        };
    }
private function getRetryFunction($shouldRetryMessages = true)
    {
        $httpRetryCodes = $this->httpRetryCodes;
        $httpRetryMessages = $this->httpRetryMessages;

        return function (\Exception $ex) use ($httpRetryCodes, $httpRetryMessages, $shouldRetryMessages) {
            $statusCode = $ex->getCode();

            if (in_array($statusCode, $httpRetryCodes)) {
                return true;
            }

            if (!$shouldRetryMessages) {
                return false;
            }

            $message = ($ex instanceof RequestException && $ex->hasResponse())
                ? (string) $ex->getResponse()->getBody()
                : $ex->getMessage();

            try {
                $message = $this->jsonDecode(
                    $message,
                    true
                );
            } catch (\InvalidArgumentException $ex) {
                return false;
            }

            if (!isset($message['error']['errors'])) {
                return false;
            }

            foreach ($message['error']['errors'] as $error) {
                if (in_array($error['reason'], $httpRetryMessages)) {
                    return true;
                }
            }

            return false;
        };
    }
private function getRetryFunction ( $ shouldRetryMessages = true ) { $ httpRetryCodes = $ this -> httpRetryCodes ; $ httpRetryMessages = $ this -> httpRetryMessages ; return function ( \ Exception $ ex ) use ( $ httpRetryCodes , $ httpRetryMessages , $ shouldRetryMessages ) { $ statusCode = $ ex -> getCode ( ) ; if ( in_array ( $ statusCode , $ httpRetryCodes ) ) { return true ; } if ( ! $ shouldRetryMessages ) { return false ; } $ message = ( $ ex instanceof RequestException && $ ex -> hasResponse ( ) ) ? ( string ) $ ex -> getResponse ( ) -> getBody ( ) : $ ex -> getMessage ( ) ; try { $ message = $ this -> jsonDecode ( $ message , true ) ; } catch ( \ InvalidArgumentException $ ex ) { return false ; } if ( ! isset ( $ message [ 'error' ] [ 'errors' ] ) ) { return false ; } foreach ( $ message [ 'error' ] [ 'errors' ] as $ error ) { if ( in_array ( $ error [ 'reason' ] , $ httpRetryMessages ) ) { return true ; } } return false ; } ; }
Determines whether or not the request should be retried.

@param bool $shouldRetryMessages Whether or not to attempt retrying based
on the failure message.
@return callable
Determines whether or not the request should be retried .