@@ -72,10 +72,11 @@ public function getFirstResult()
7272 *
7373 * @param string
7474 * @return string
75- * @throws CommonException\ApiException\ApiException
76- * @throws CommonException\ApiException\ApiLimitException
77- * @throws CommonException\ApiException\ApiNoResultsException
78- * @throws CommonException\ApiException\NetworkException
75+ * @throws CommonException\ApiException\AuthenticationException
76+ * @throws CommonException\ApiException\InvalidResponseException
77+ * @throws CommonException\ApiException\NoResultException
78+ * @throws CommonException\ApiException\RequestQuotaException
79+ * @throws CommonException\NetworkException\CurlException
7980 */
8081 protected function request ($ url )
8182 {
@@ -85,7 +86,7 @@ protected function request($url)
8586 $ response = curl_exec ($ curl );
8687 curl_close ($ curl );
8788 if (!$ response ) {
88- throw new CommonException \ApiException \ NetworkException ('Curling the API endpoint ' . $ url . ' failed. ' );
89+ throw new CommonException \NetworkException \ CurlException ('Curling the API endpoint ' . $ url . ' failed. ' );
8990 }
9091 $ responseData = @json_decode ($ response , true );
9192 $ this ->validateResponse ($ response , $ responseData );
@@ -95,26 +96,27 @@ protected function request($url)
9596 /**
9697 * @param string $rawResponse
9798 * @param array|string $responseData
98- * @throws CommonException\ApiException\ApiException
99- * @throws CommonException\ApiException\ApiLimitException
100- * @throws CommonException\ApiException\ApiNoResultsException
99+ * @throws CommonException\ApiException\AuthenticationException
100+ * @throws CommonException\ApiException\InvalidResponseException
101+ * @throws CommonException\ApiException\NoResultException
102+ * @throws CommonException\ApiException\RequestQuotaException
101103 */
102104 private function validateResponse ($ rawResponse , $ responseData )
103105 {
104106 if (is_null ($ responseData ) || !is_array ($ responseData ) || !isset ($ responseData ['status ' ])) {
105- throw new CommonException \ApiException \ApiException ('Parsing the API response from body failed: ' . $ rawResponse );
107+ throw new CommonException \ApiException \InvalidResponseException ('Parsing the API response from body failed: ' . $ rawResponse );
106108 }
107109
108110 $ responseStatus = mb_strtoupper ($ responseData ['status ' ]);
109111 if ($ responseStatus == 'OVER_QUERY_LIMIT ' ) {
110112 $ exceptionMessage = $ this ->buildExceptionMessage ('Google Geocoder request limit reached ' , $ responseData );
111- throw new CommonException \ApiException \ApiLimitException ($ exceptionMessage );
113+ throw new CommonException \ApiException \RequestQuotaException ($ exceptionMessage );
112114 } else if ($ responseStatus == 'REQUEST_DENIED ' ) {
113115 $ exceptionMessage = $ this ->buildExceptionMessage ('Google Geocoder request was denied ' , $ responseData );
114- throw new CommonException \ApiException \ApiException ($ exceptionMessage );
116+ throw new CommonException \ApiException \AuthenticationException ($ exceptionMessage );
115117 } else if ($ responseStatus != 'OK ' ) {
116118 $ exceptionMessage = $ this ->buildExceptionMessage ('Google Geocoder no results ' , $ responseData );
117- throw new CommonException \ApiException \ApiNoResultsException ($ exceptionMessage );
119+ throw new CommonException \ApiException \NoResultException ($ exceptionMessage );
118120 }
119121 }
120122
0 commit comments