Odesk\Phystrix\AbstractCommand::getFallbackOrThrowException PHP Method

getFallbackOrThrowException() private method

Attempts to retrieve fallback by calling getFallback
private getFallbackOrThrowException ( Exception $originalException = null ) : mixed
$originalException Exception (Optional) If null, the request was short-circuited
return mixed
    private function getFallbackOrThrowException(Exception $originalException = null)
    {
        $metrics = $this->getMetrics();
        $message = $originalException === null ? 'Short-circuited' : $originalException->getMessage();
        try {
            if ($this->config->get('fallback')->get('enabled')) {
                try {
                    $executionResult = $this->getFallback();
                    $metrics->markFallbackSuccess();
                    $this->recordExecutionEvent(self::EVENT_FALLBACK_SUCCESS);
                    return $executionResult;
                } catch (FallbackNotAvailableException $fallbackException) {
                    throw new RuntimeException($message . ' and no fallback available', get_class($this), $originalException);
                } catch (Exception $fallbackException) {
                    $metrics->markFallbackFailure();
                    $this->recordExecutionEvent(self::EVENT_FALLBACK_FAILURE);
                    throw new RuntimeException($message . ' and failed retrieving fallback', get_class($this), $originalException, $fallbackException);
                }
            } else {
                throw new RuntimeException($message . ' and fallback disabled', get_class($this), $originalException);
            }
        } catch (Exception $exception) {
            // count that we are throwing an exception and re-throw it
            $metrics->markExceptionThrown();
            $this->recordExecutionEvent(self::EVENT_EXCEPTION_THROWN);
            throw $exception;
        }
    }