Rename GenericException to GeoIP2Exception
This commit is contained in:
parent
73d6f15823
commit
b179e29ee7
|
@ -93,7 +93,7 @@ If the web service returns any status code besides 200, 4xx, or 5xx, this also
|
||||||
becomes a ```\GeoIP2\Exception\HttpException```.
|
becomes a ```\GeoIP2\Exception\HttpException```.
|
||||||
|
|
||||||
Finally, if the web service returns a 200 but the body is invalid, the client
|
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? ##
|
## What data is returned? ##
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace GeoIP2\Exception;
|
||||||
/**
|
/**
|
||||||
* This class represents a generic error.
|
* This class represents a generic error.
|
||||||
*/
|
*/
|
||||||
class GenericException extends \Exception
|
class GeoIP2Exception extends \Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ namespace GeoIP2\Exception;
|
||||||
* This class represents an HTTP transport error.
|
* This class represents an HTTP transport error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class HttpException extends GenericException
|
class HttpException extends GeoIP2Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The URI queried
|
* The URI queried
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace GeoIP2\WebService;
|
namespace GeoIP2\WebService;
|
||||||
|
|
||||||
use GeoIP2\Exception\GenericException;
|
use GeoIP2\Exception\GeoIP2Exception;
|
||||||
use GeoIP2\Exception\HttpException;
|
use GeoIP2\Exception\HttpException;
|
||||||
use GeoIP2\Exception\WebServiceException;
|
use GeoIP2\Exception\WebServiceException;
|
||||||
use GeoIP2\Model\City;
|
use GeoIP2\Model\City;
|
||||||
|
@ -63,7 +63,7 @@ use Guzzle\Http\Exception\ServerErrorResponseException;
|
||||||
* also becomes a {@link \GeoIP2\Exception\HttpException}.
|
* also becomes a {@link \GeoIP2\Exception\HttpException}.
|
||||||
*
|
*
|
||||||
* Finally, if the web service returns a 200 but the body is invalid, the
|
* 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
|
class Client
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ class Client
|
||||||
*
|
*
|
||||||
* @return \GeoIP2\Model\City
|
* @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.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
|
@ -129,7 +129,7 @@ class Client
|
||||||
*
|
*
|
||||||
* @return \GeoIP2\Model\Country
|
* @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.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
|
@ -150,7 +150,7 @@ class Client
|
||||||
*
|
*
|
||||||
* @return \GeoIP2\Model\CityIspOrg
|
* @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.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
|
@ -171,7 +171,7 @@ class Client
|
||||||
*
|
*
|
||||||
* @return \GeoIP2\Model\Omni
|
* @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.
|
* error processing your request.
|
||||||
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
* @throws \GeoIP2\Exception\HttpException if there was an HTTP transport
|
||||||
* error.
|
* error.
|
||||||
|
@ -216,7 +216,7 @@ class Client
|
||||||
private function handleSuccess($response, $uri)
|
private function handleSuccess($response, $uri)
|
||||||
{
|
{
|
||||||
if ($response->getContentLength() == 0) {
|
if ($response->getContentLength() == 0) {
|
||||||
throw new GenericException(
|
throw new GeoIP2Exception(
|
||||||
"Received a 200 response for $uri but did not " .
|
"Received a 200 response for $uri but did not " .
|
||||||
"receive a HTTP body."
|
"receive a HTTP body."
|
||||||
);
|
);
|
||||||
|
@ -225,7 +225,7 @@ class Client
|
||||||
try {
|
try {
|
||||||
return $response->json();
|
return $response->json();
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
throw new GenericException(
|
throw new GeoIP2Exception(
|
||||||
"Received a 200 response for $uri but could not decode " .
|
"Received a 200 response for $uri but could not decode " .
|
||||||
"the response as JSON: " . $e->getMessage()
|
"the response as JSON: " . $e->getMessage()
|
||||||
);
|
);
|
||||||
|
@ -244,7 +244,7 @@ class Client
|
||||||
try {
|
try {
|
||||||
$body = $response->json();
|
$body = $response->json();
|
||||||
if (!isset($body['code']) || !isset($body['error'])) {
|
if (!isset($body['code']) || !isset($body['error'])) {
|
||||||
throw new GenericException(
|
throw new GeoIP2Exception(
|
||||||
'Response contains JSON but it does not specify ' .
|
'Response contains JSON but it does not specify ' .
|
||||||
'code or error keys: ' . $response->getBody()
|
'code or error keys: ' . $response->getBody()
|
||||||
);
|
);
|
||||||
|
|
|
@ -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.
|
* @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()
|
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:
|
* @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()
|
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
|
* @expectedExceptionMessage Response contains JSON but it does not specify code or error keys
|
||||||
*/
|
*/
|
||||||
public function testWeirdErrorBodyIPException()
|
public function testWeirdErrorBodyIPException()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user