Little fix in responseHandler switch case:

throwing exception prevents next code execution, so it was unnecessary to use breaks. And also use return in case that differs from 200
This commit is contained in:
temirkhan 2016-04-20 12:00:50 +03:00
parent 2d9cd57d2e
commit 30b4aa5e9a

View File

@ -206,24 +206,18 @@ class RestClient
$result = new \stdClass();
// return response data as json if possible, raw if not
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
break;
case 400:
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj));
break;
case 401:
throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS);
break;
case 404:
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj));
break;
default:
throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
break;
}
$result->http_response_code = $httpResponseCode;
return $result;
case 400:
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj));
case 401:
throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS);
case 404:
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj));
default:
throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
}
}
/**