コード例 #1
0
ファイル: Standard.php プロジェクト: Rodrifer/candyclub
 /**
  * @see parent
  * @param Bronto_Api_Exception $exception
  * @param Bronto_Api $api
  * @param Bronto_Object $request
  * @return boolean
  */
 public function recover(Bronto_Api_Exception $exception, Bronto_Api $api, Bronto_Object $request)
 {
     $canRetry = $exception->getAttempts() < $api->getOptions()->getRetries();
     if ($exception->isRecoverable() && $canRetry) {
         if ($exception->isInvalidSession()) {
             $api->login();
             return true;
         } else {
             if ($exception->isNetworkRelated() && !$request->hasUpdates()) {
                 // Incrementally backoff the read request
                 $backOff = $api->getOptions()->getBackOff() * $exception->getAttempts();
                 sleep($backOff);
                 return true;
             }
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Api.php プロジェクト: gelaru/bronto-api-php-client
 /**
  * We want all Exceptions to be Bronto_Api_Exception for request/response
  *
  * @param string|Exception $exception
  * @param string $message
  * @param string $code
  * @return Bronto_Api_Exception
  */
 public function throwException($exception, $message = null, $code = null)
 {
     if ($exception instanceof Exception) {
         if ($exception instanceof Bronto_Api_Exception) {
             // Good
         } else {
             // Convert
             $exception = new Bronto_Api_Exception($exception->getMessage(), $exception->getCode(), null, $exception);
         }
     } else {
         if (is_string($exception)) {
             if (class_exists($exception, false)) {
                 $exception = new $exception($message, $code);
             } else {
                 $exception = new Bronto_Api_Exception($exception);
             }
         }
     }
     // For tracking request/response in debug mode
     if ($this->getDebug()) {
         /* @var $exception Bronto_Api_Exception */
         $exception->setRequest($this->getLastRequest());
         $exception->setResponse($this->getLastResponse());
     }
     // Allow observer to handle exception cases
     if ($this->getObserver()) {
         $this->getObserver()->onError($this, $exception);
     }
     throw $exception;
 }
コード例 #3
0
ファイル: Api.php プロジェクト: bevello/bevello
 /**
  * @see parent
  *
  * @param Bronto_Api $api
  * @param Bronto_Api_Exception $exception
  */
 public function onError($api, $exception)
 {
     if ($exception instanceof Bronto_Api_Exception) {
         if ($request = $exception->getRequest()) {
             Mage::helper('bronto_common')->writeDebug(var_export($request, true));
         }
         if ($response = $exception->getResponse()) {
             Mage::helper('bronto_common')->writeDebug(var_export($response, true));
         }
     }
 }