library/Odesk/Phystrix/AbstractCommand.php
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;
        }
    }
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;
        }
    }
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 ; } }
Attempts to retrieve fallback by calling getFallback

@param Exception $originalException (Optional) If null, the request was short-circuited
@return mixed
@throws RuntimeException When fallback is disabled, not available for the command, or failed retrieving
@throws Exception
Attempts to retrieve fallback by calling getFallback