Skip to content

Commit 6d287c8

Browse files
committed
Use NetacuityException
1 parent 9afdd9c commit 6d287c8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Databases/AbstractNetAcuityDatabase.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace TraderInteractive\NetAcuity\Databases;
44

5+
use TraderInteractive\NetAcuity\Exceptions\NetacuityException;
56
use TraderInteractive\Util\Arrays;
6-
use Exception;
77
use GuzzleHttp\ClientInterface;
88
use GuzzleHttp\Exception\ClientException;
99
use GuzzleHttp\Psr7\Request;
@@ -66,7 +66,7 @@ public function __construct(
6666
*
6767
* @return array The formatted data set.
6868
*
69-
* @throws Exception On failure to send a Guzzle request.
69+
* @throws NetacuityException On failure to send a Guzzle request.
7070
*/
7171
public function fetch(string $ip)
7272
{
@@ -87,7 +87,7 @@ public function fetch(string $ip)
8787
/**
8888
* @param ClientException $e The thrown exception for handling.
8989
*
90-
* @throws Exception A formatted exception masking the API User Token in the event that it becomes invalid.
90+
* @throws NetacuityException A formatted exception masking the API User Token in the event that it becomes invalid.
9191
*
9292
* @return void
9393
*/
@@ -97,13 +97,13 @@ protected function handleGuzzleException(ClientException $e)
9797
$code = $response->getStatusCode();
9898

9999
if ($code === 403) {
100-
throw new Exception('NetAcuity API rejected the provided api user token.', $code);
100+
throw new NetacuityException('NetAcuity API rejected the provided api user token.', $code);
101101
}
102102

103103
$error = json_decode($response->getBody()->getContents(), true);
104104
$reason = Arrays::getNested($error, 'error.message');
105105

106-
throw new Exception("NetAcuity API rejected the request, Reason: {$reason}", $code);
106+
throw new NetacuityException("NetAcuity API rejected the request, Reason: {$reason}", $code);
107107
}
108108

109109
/**

tests/Databases/AbstractNetAcuityDatabaseTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace TraderInteractive\NetAcuity\Databases\Tests;
44

55
use TraderInteractive\NetAcuity\Databases\EdgeDatabase;
6+
use TraderInteractive\NetAcuity\Exceptions\NetacuityException;
67
use TraderInteractive\NetAcuity\Tests\NetAcuityTestSuite;
78
use Exception;
89

@@ -154,6 +155,7 @@ public function getGeoWithExtraFieldEdge()
154155
*/
155156
public function getGeoNonStringIp()
156157
{
158+
$this->expectException(NetacuityException::class);
157159
$this->expectExceptionMessage('NetAcuity API rejected the request, Reason: Invalid IP (1)');
158160
$this->expectExceptionCode(400);
159161

@@ -171,6 +173,7 @@ public function getGeoNonStringIp()
171173
*/
172174
public function netAcuityUserTokenInvalid()
173175
{
176+
$this->expectException(NetacuityException::class);
174177
$this->expectExceptionMessage('NetAcuity API rejected the provided api user token.');
175178
$this->expectExceptionCode(403);
176179

0 commit comments

Comments
 (0)