Skip to content

Commit

Permalink
Add typed exception for PersonatorRequestException.php to support uni…
Browse files Browse the repository at this point in the history
…t tests for error cases
  • Loading branch information
zstein-holts committed Mar 10, 2020
1 parent df8533b commit bf5c9a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Personator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function __construct(string $licenseKey) {
* @return PersonatorResult
* @throws GuzzleException
* @throws InvalidArgumentException
* @throws PersonatorRequestException
*/
public function doRequest(array $actions, array $addressParams) {
if (count($actions) === 0 || (count($actions) != count(array_intersect($actions, $this->validActions))) ) {
Expand All @@ -64,7 +65,7 @@ public function doRequest(array $actions, array $addressParams) {
'query' => $params
] );
if ($response->getStatusCode() != 200) {
throw new Exception('Invalid response from melissa! ' .$response->getStatusCode());
throw new PersonatorRequestException('Invalid response from melissa! ' .$response->getStatusCode());
}

$result = new PersonatorResult($response->getBody());
Expand Down
8 changes: 8 additions & 0 deletions lib/PersonatorRequestException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php


namespace Holtsdev\Personator;


class PersonatorRequestException extends \Exception {
}

0 comments on commit bf5c9a9

Please sign in to comment.