diff --git a/README.md b/README.md index fc58923..f05a301 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ If the web service returns any status code besides 200, 4xx, or 5xx, this also becomes a ```\GeoIP2\Exception\HttpException```. Finally, if the web service returns a 200 but the body is invalid, the client -throws a ```\GeoIP2\Exception\GenericException```. +throws a ```\GeoIP2\Exception\GeoIP2Exception```. ## What data is returned? ## diff --git a/src/GeoIP2/Exception/GenericException.php b/src/GeoIP2/Exception/GeoIP2Exception.php similarity index 68% rename from src/GeoIP2/Exception/GenericException.php rename to src/GeoIP2/Exception/GeoIP2Exception.php index 7195e6c..1e0c9a6 100644 --- a/src/GeoIP2/Exception/GenericException.php +++ b/src/GeoIP2/Exception/GeoIP2Exception.php @@ -5,6 +5,6 @@ namespace GeoIP2\Exception; /** * This class represents a generic error. */ -class GenericException extends \Exception +class GeoIP2Exception extends \Exception { } diff --git a/src/GeoIP2/Exception/HttpException.php b/src/GeoIP2/Exception/HttpException.php index e0e3851..5343017 100644 --- a/src/GeoIP2/Exception/HttpException.php +++ b/src/GeoIP2/Exception/HttpException.php @@ -6,7 +6,7 @@ namespace GeoIP2\Exception; * This class represents an HTTP transport error. */ -class HttpException extends GenericException +class HttpException extends GeoIP2Exception { /** * The URI queried diff --git a/src/GeoIP2/WebService/Client.php b/src/GeoIP2/WebService/Client.php index 5b4a334..9581bee 100644 --- a/src/GeoIP2/WebService/Client.php +++ b/src/GeoIP2/WebService/Client.php @@ -2,7 +2,7 @@ namespace GeoIP2\WebService; -use GeoIP2\Exception\GenericException; +use GeoIP2\Exception\GeoIP2Exception; use GeoIP2\Exception\HttpException; use GeoIP2\Exception\WebServiceException; use GeoIP2\Model\City; @@ -63,7 +63,7 @@ use Guzzle\Http\Exception\ServerErrorResponseException; * also becomes a {@link \GeoIP2\Exception\HttpException}. * * Finally, if the web service returns a 200 but the body is invalid, the - * client throws a {@link \GeoIP2\Exception\GenericException}. + * client throws a {@link \GeoIP2\Exception\GeoIP2Exception}. */ class Client { @@ -108,7 +108,7 @@ class Client * * @return \GeoIP2\Model\City * - * @throws \GeoIP2\Exception\GenericException if there was a generic + * @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic * error processing your request. * @throws \GeoIP2\Exception\HttpException if there was an HTTP transport * error. @@ -129,7 +129,7 @@ class Client * * @return \GeoIP2\Model\Country * - * @throws \GeoIP2\Exception\GenericException if there was a generic + * @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic * error processing your request. * @throws \GeoIP2\Exception\HttpException if there was an HTTP transport * error. @@ -150,7 +150,7 @@ class Client * * @return \GeoIP2\Model\CityIspOrg * - * @throws \GeoIP2\Exception\GenericException if there was a generic + * @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic * error processing your request. * @throws \GeoIP2\Exception\HttpException if there was an HTTP transport * error. @@ -171,7 +171,7 @@ class Client * * @return \GeoIP2\Model\Omni * - * @throws \GeoIP2\Exception\GenericException if there was a generic + * @throws \GeoIP2\Exception\GeoIP2Exception if there was a generic * error processing your request. * @throws \GeoIP2\Exception\HttpException if there was an HTTP transport * error. @@ -216,7 +216,7 @@ class Client private function handleSuccess($response, $uri) { if ($response->getContentLength() == 0) { - throw new GenericException( + throw new GeoIP2Exception( "Received a 200 response for $uri but did not " . "receive a HTTP body." ); @@ -225,7 +225,7 @@ class Client try { return $response->json(); } catch (RuntimeException $e) { - throw new GenericException( + throw new GeoIP2Exception( "Received a 200 response for $uri but could not decode " . "the response as JSON: " . $e->getMessage() ); @@ -244,7 +244,7 @@ class Client try { $body = $response->json(); if (!isset($body['code']) || !isset($body['error'])) { - throw new GenericException( + throw new GeoIP2Exception( 'Response contains JSON but it does not specify ' . 'code or error keys: ' . $response->getBody() ); diff --git a/tests/GeoIP2/Test/WebService/ClientTest.php b/tests/GeoIP2/Test/WebService/ClientTest.php index bcea848..28926e3 100644 --- a/tests/GeoIP2/Test/WebService/ClientTest.php +++ b/tests/GeoIP2/Test/WebService/ClientTest.php @@ -176,7 +176,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException GeoIP2\Exception\GenericException + * @expectedException GeoIP2\Exception\GeoIP2Exception * @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.0/country/1.2.3.5 but did not receive a HTTP body. */ public function testNoBodyException() @@ -187,7 +187,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException GeoIP2\Exception\GenericException + * @expectedException GeoIP2\Exception\GeoIP2Exception * @expectedExceptionMessage Received a 200 response for https://geoip.maxmind.com/geoip/v2.0/country/2.2.3.5 but could not decode the response as JSON: */ public function testBadBodyException() @@ -224,7 +224,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException GeoIP2\Exception\GenericException + * @expectedException GeoIP2\Exception\GeoIP2Exception * @expectedExceptionMessage Response contains JSON but it does not specify code or error keys */ public function testWeirdErrorBodyIPException()