Skip to content

Commit

Permalink
Make sure we are always throwing an exception from Core (#841)
Browse files Browse the repository at this point in the history
* Make sure we are always throwing an exception from Core

* Make sure we generate classes to throw correct exception

* ./generate --all

* Shorten name

* Do cover integrations

* Added changelog
  • Loading branch information
Nyholm authored Nov 3, 2020
1 parent 4cbe898 commit e2f092b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/Result/ListQueuesResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AsyncAws\Sqs\Result;

use AsyncAws\Core\Exception\InvalidArgument;
use AsyncAws\Core\Response;
use AsyncAws\Core\Result;
use AsyncAws\Sqs\Input\ListQueuesRequest;
Expand Down Expand Up @@ -32,10 +33,10 @@ public function getIterator(): \Traversable
{
$client = $this->awsClient;
if (!$client instanceof SqsClient) {
throw new \InvalidArgumentException('missing client injected in paginated result');
throw new InvalidArgument('missing client injected in paginated result');
}
if (!$this->input instanceof ListQueuesRequest) {
throw new \InvalidArgumentException('missing last request injected in paginated result');
throw new InvalidArgument('missing last request injected in paginated result');
}
$input = clone $this->input;
$page = $this;
Expand Down Expand Up @@ -82,10 +83,10 @@ public function getQueueUrls(bool $currentPageOnly = false): iterable

$client = $this->awsClient;
if (!$client instanceof SqsClient) {
throw new \InvalidArgumentException('missing client injected in paginated result');
throw new InvalidArgument('missing client injected in paginated result');
}
if (!$this->input instanceof ListQueuesRequest) {
throw new \InvalidArgumentException('missing last request injected in paginated result');
throw new InvalidArgument('missing last request injected in paginated result');
}
$input = clone $this->input;
$page = $this;
Expand Down
5 changes: 3 additions & 2 deletions src/Result/QueueExistsWaiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace AsyncAws\Sqs\Result;

use AsyncAws\Core\Exception\Http\HttpException;
use AsyncAws\Core\Exception\InvalidArgument;
use AsyncAws\Core\Response;
use AsyncAws\Core\Waiter;
use AsyncAws\Sqs\Input\GetQueueUrlRequest;
Expand Down Expand Up @@ -30,10 +31,10 @@ protected function extractState(Response $response, ?HttpException $exception):
protected function refreshState(): Waiter
{
if (!$this->awsClient instanceof SqsClient) {
throw new \InvalidArgumentException('missing client injected in waiter result');
throw new InvalidArgument('missing client injected in waiter result');
}
if (!$this->input instanceof GetQueueUrlRequest) {
throw new \InvalidArgumentException('missing last request injected in waiter result');
throw new InvalidArgument('missing last request injected in waiter result');
}

return $this->awsClient->QueueExists($this->input);
Expand Down

0 comments on commit e2f092b

Please sign in to comment.