Skip to content

Commit 5be0ea4

Browse files
authored
Generate Exceptions (#921)
* Generate Exceptions * Add documentation on top of class * Leverage the new AwsErrorFactory * Fix __constructor signature in GeneratedException * Fix private vs protected * Generate all methods * Fix things * Add constraint in composer.Json * Add changelog entry
1 parent d86994b commit 5be0ea4

12 files changed

+387
-21
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Changed case of object's properties to camelCase.
88
- Added documentation in class's headers.
9+
- Added Business Exceptions.
910

1011
## 1.0.1
1112

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"php": "^7.2.5 || ^8.0",
1515
"ext-filter": "*",
1616
"ext-json": "*",
17-
"async-aws/core": "^1.2"
17+
"async-aws/core": "^1.9"
1818
},
1919
"conflict": {
2020
"symfony/http-client": "<4.4.16,<5.1.7"

src/DynamoDbClient.php

+179-20
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* A condition specified in the operation could not be evaluated.
10+
*/
11+
final class ConditionalCheckFailedException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = $response->toArray(false);
16+
17+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
18+
$this->message = $v;
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* An error occurred on the server side.
10+
*/
11+
final class InternalServerErrorException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = $response->toArray(false);
16+
17+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
18+
$this->message = $v;
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* An item collection is too large. This exception is only returned for tables that have one or more local secondary
10+
* indexes.
11+
*/
12+
final class ItemCollectionSizeLimitExceededException extends ClientException
13+
{
14+
protected function populateResult(ResponseInterface $response): void
15+
{
16+
$data = $response->toArray(false);
17+
18+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
19+
$this->message = $v;
20+
}
21+
}
22+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* There is no limit to the number of daily on-demand backups that can be taken.
10+
* Up to 50 simultaneous table operations are allowed per account. These operations include `CreateTable`,
11+
* `UpdateTable`, `DeleteTable`,`UpdateTimeToLive`, `RestoreTableFromBackup`, and `RestoreTableToPointInTime`.
12+
* The only exception is when you are creating a table with one or more secondary indexes. You can have up to 25 such
13+
* requests running at a time; however, if the table or index specifications are complex, DynamoDB might temporarily
14+
* reduce the number of concurrent operations.
15+
* There is a soft account quota of 256 tables.
16+
*/
17+
final class LimitExceededException extends ClientException
18+
{
19+
protected function populateResult(ResponseInterface $response): void
20+
{
21+
$data = $response->toArray(false);
22+
23+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
24+
$this->message = $v;
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests that receive this exception.
10+
* Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of
11+
* requests and use exponential backoff. For more information, go to Error Retries and Exponential Backoff in the
12+
* *Amazon DynamoDB Developer Guide*.
13+
*
14+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff
15+
*/
16+
final class ProvisionedThroughputExceededException extends ClientException
17+
{
18+
protected function populateResult(ResponseInterface $response): void
19+
{
20+
$data = $response->toArray(false);
21+
22+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
23+
$this->message = $v;
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Throughput exceeds the current throughput quota for your account. Please contact AWS Support at AWS Support to
10+
* request a quota increase.
11+
*
12+
* @see https://aws.amazon.com/support
13+
*/
14+
final class RequestLimitExceededException extends ClientException
15+
{
16+
protected function populateResult(ResponseInterface $response): void
17+
{
18+
$data = $response->toArray(false);
19+
20+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
21+
$this->message = $v;
22+
}
23+
}
24+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* The operation conflicts with the resource's availability. For example, you attempted to recreate an existing table,
10+
* or tried to delete a table currently in the `CREATING` state.
11+
*/
12+
final class ResourceInUseException extends ClientException
13+
{
14+
protected function populateResult(ResponseInterface $response): void
15+
{
16+
$data = $response->toArray(false);
17+
18+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
19+
$this->message = $v;
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its
10+
* status might not be `ACTIVE`.
11+
*/
12+
final class ResourceNotFoundException extends ClientException
13+
{
14+
protected function populateResult(ResponseInterface $response): void
15+
{
16+
$data = $response->toArray(false);
17+
18+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
19+
$this->message = $v;
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace AsyncAws\DynamoDb\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Operation was rejected because there is an ongoing transaction for the item.
10+
*/
11+
final class TransactionConflictException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = $response->toArray(false);
16+
17+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
18+
$this->message = $v;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)