Skip to content

Commit 7e9488d

Browse files
authored
Make sure we are always throwing an exception from Core (#841)
* 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
1 parent b694589 commit 7e9488d

6 files changed

+26
-20
lines changed

src/Result/BatchGetItemOutput.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\DynamoDb\Result;
44

5+
use AsyncAws\Core\Exception\InvalidArgument;
56
use AsyncAws\Core\Response;
67
use AsyncAws\Core\Result;
78
use AsyncAws\DynamoDb\DynamoDbClient;
@@ -50,10 +51,10 @@ public function getConsumedCapacity(bool $currentPageOnly = false): iterable
5051

5152
$client = $this->awsClient;
5253
if (!$client instanceof DynamoDbClient) {
53-
throw new \InvalidArgumentException('missing client injected in paginated result');
54+
throw new InvalidArgument('missing client injected in paginated result');
5455
}
5556
if (!$this->input instanceof BatchGetItemInput) {
56-
throw new \InvalidArgumentException('missing last request injected in paginated result');
57+
throw new InvalidArgument('missing last request injected in paginated result');
5758
}
5859
$input = clone $this->input;
5960
$page = $this;
@@ -86,10 +87,10 @@ public function getIterator(): \Traversable
8687
{
8788
$client = $this->awsClient;
8889
if (!$client instanceof DynamoDbClient) {
89-
throw new \InvalidArgumentException('missing client injected in paginated result');
90+
throw new InvalidArgument('missing client injected in paginated result');
9091
}
9192
if (!$this->input instanceof BatchGetItemInput) {
92-
throw new \InvalidArgumentException('missing last request injected in paginated result');
93+
throw new InvalidArgument('missing last request injected in paginated result');
9394
}
9495
$input = clone $this->input;
9596
$page = $this;

src/Result/ListTablesOutput.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\DynamoDb\Result;
44

5+
use AsyncAws\Core\Exception\InvalidArgument;
56
use AsyncAws\Core\Response;
67
use AsyncAws\Core\Result;
78
use AsyncAws\DynamoDb\DynamoDbClient;
@@ -33,10 +34,10 @@ public function getIterator(): \Traversable
3334
{
3435
$client = $this->awsClient;
3536
if (!$client instanceof DynamoDbClient) {
36-
throw new \InvalidArgumentException('missing client injected in paginated result');
37+
throw new InvalidArgument('missing client injected in paginated result');
3738
}
3839
if (!$this->input instanceof ListTablesInput) {
39-
throw new \InvalidArgumentException('missing last request injected in paginated result');
40+
throw new InvalidArgument('missing last request injected in paginated result');
4041
}
4142
$input = clone $this->input;
4243
$page = $this;
@@ -83,10 +84,10 @@ public function getTableNames(bool $currentPageOnly = false): iterable
8384

8485
$client = $this->awsClient;
8586
if (!$client instanceof DynamoDbClient) {
86-
throw new \InvalidArgumentException('missing client injected in paginated result');
87+
throw new InvalidArgument('missing client injected in paginated result');
8788
}
8889
if (!$this->input instanceof ListTablesInput) {
89-
throw new \InvalidArgumentException('missing last request injected in paginated result');
90+
throw new InvalidArgument('missing last request injected in paginated result');
9091
}
9192
$input = clone $this->input;
9293
$page = $this;

src/Result/QueryOutput.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\DynamoDb\Result;
44

5+
use AsyncAws\Core\Exception\InvalidArgument;
56
use AsyncAws\Core\Response;
67
use AsyncAws\Core\Result;
78
use AsyncAws\DynamoDb\DynamoDbClient;
@@ -81,10 +82,10 @@ public function getItems(bool $currentPageOnly = false): iterable
8182

8283
$client = $this->awsClient;
8384
if (!$client instanceof DynamoDbClient) {
84-
throw new \InvalidArgumentException('missing client injected in paginated result');
85+
throw new InvalidArgument('missing client injected in paginated result');
8586
}
8687
if (!$this->input instanceof QueryInput) {
87-
throw new \InvalidArgumentException('missing last request injected in paginated result');
88+
throw new InvalidArgument('missing last request injected in paginated result');
8889
}
8990
$input = clone $this->input;
9091
$page = $this;
@@ -117,10 +118,10 @@ public function getIterator(): \Traversable
117118
{
118119
$client = $this->awsClient;
119120
if (!$client instanceof DynamoDbClient) {
120-
throw new \InvalidArgumentException('missing client injected in paginated result');
121+
throw new InvalidArgument('missing client injected in paginated result');
121122
}
122123
if (!$this->input instanceof QueryInput) {
123-
throw new \InvalidArgumentException('missing last request injected in paginated result');
124+
throw new InvalidArgument('missing last request injected in paginated result');
124125
}
125126
$input = clone $this->input;
126127
$page = $this;

src/Result/ScanOutput.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\DynamoDb\Result;
44

5+
use AsyncAws\Core\Exception\InvalidArgument;
56
use AsyncAws\Core\Response;
67
use AsyncAws\Core\Result;
78
use AsyncAws\DynamoDb\DynamoDbClient;
@@ -81,10 +82,10 @@ public function getItems(bool $currentPageOnly = false): iterable
8182

8283
$client = $this->awsClient;
8384
if (!$client instanceof DynamoDbClient) {
84-
throw new \InvalidArgumentException('missing client injected in paginated result');
85+
throw new InvalidArgument('missing client injected in paginated result');
8586
}
8687
if (!$this->input instanceof ScanInput) {
87-
throw new \InvalidArgumentException('missing last request injected in paginated result');
88+
throw new InvalidArgument('missing last request injected in paginated result');
8889
}
8990
$input = clone $this->input;
9091
$page = $this;
@@ -117,10 +118,10 @@ public function getIterator(): \Traversable
117118
{
118119
$client = $this->awsClient;
119120
if (!$client instanceof DynamoDbClient) {
120-
throw new \InvalidArgumentException('missing client injected in paginated result');
121+
throw new InvalidArgument('missing client injected in paginated result');
121122
}
122123
if (!$this->input instanceof ScanInput) {
123-
throw new \InvalidArgumentException('missing last request injected in paginated result');
124+
throw new InvalidArgument('missing last request injected in paginated result');
124125
}
125126
$input = clone $this->input;
126127
$page = $this;

src/Result/TableExistsWaiter.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Result;
44

55
use AsyncAws\Core\Exception\Http\HttpException;
6+
use AsyncAws\Core\Exception\InvalidArgument;
67
use AsyncAws\Core\Response;
78
use AsyncAws\Core\Waiter;
89
use AsyncAws\DynamoDb\DynamoDbClient;
@@ -30,10 +31,10 @@ protected function extractState(Response $response, ?HttpException $exception):
3031
protected function refreshState(): Waiter
3132
{
3233
if (!$this->awsClient instanceof DynamoDbClient) {
33-
throw new \InvalidArgumentException('missing client injected in waiter result');
34+
throw new InvalidArgument('missing client injected in waiter result');
3435
}
3536
if (!$this->input instanceof DescribeTableInput) {
36-
throw new \InvalidArgumentException('missing last request injected in waiter result');
37+
throw new InvalidArgument('missing last request injected in waiter result');
3738
}
3839

3940
return $this->awsClient->TableExists($this->input);

src/Result/TableNotExistsWaiter.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace AsyncAws\DynamoDb\Result;
44

55
use AsyncAws\Core\Exception\Http\HttpException;
6+
use AsyncAws\Core\Exception\InvalidArgument;
67
use AsyncAws\Core\Response;
78
use AsyncAws\Core\Waiter;
89
use AsyncAws\DynamoDb\DynamoDbClient;
@@ -26,10 +27,10 @@ protected function extractState(Response $response, ?HttpException $exception):
2627
protected function refreshState(): Waiter
2728
{
2829
if (!$this->awsClient instanceof DynamoDbClient) {
29-
throw new \InvalidArgumentException('missing client injected in waiter result');
30+
throw new InvalidArgument('missing client injected in waiter result');
3031
}
3132
if (!$this->input instanceof DescribeTableInput) {
32-
throw new \InvalidArgumentException('missing last request injected in waiter result');
33+
throw new InvalidArgument('missing last request injected in waiter result');
3334
}
3435

3536
return $this->awsClient->TableNotExists($this->input);

0 commit comments

Comments
 (0)