Пример #1
0
 /**
  * Inspect the provided Guzzle ClientException, and transform it into an
  * appropriate Sportily Error.
  *
  * @param GuzzleHttp\Exception\ClientException $e the client exception to inspect
  */
 private static function processClientException($e)
 {
     $json = $e->getResponse()->json();
     switch ($json['error']) {
         case 'invalid_data':
             throw new Error\Validation($json['error_description'], $json['validation_messages']);
         default:
             throw new Error\Base(json_encode($json));
     }
 }
Пример #2
0
 /**
  * Method will elaborate on RequestException
  * @param  GuzzleHttp\Exception\ClientException $e
  * @return mixed
  */
 private function assignExceptions($e)
 {
     if ($e->hasResponse() && $e->getResponse()->getStatusCode() == '401') {
         throw new TokenExpiredException(sprintf("Salesforce token has expired"));
     } else {
         if ($e->hasResponse()) {
             throw new SalesforceException(sprintf("Salesforce response error: %s", $e->getResponse()));
         } else {
             throw new SalesforceException(sprintf("Invalid request: %s", $e->getRequest()));
         }
     }
 }