Skip to content

Commit db815fd

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 6a97ee4 commit db815fd

24 files changed

+645
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
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.1.1
1112

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"require": {
1414
"php": "^7.2.5 || ^8.0",
1515
"ext-SimpleXML": "*",
16-
"async-aws/core": "^1.2"
16+
"async-aws/core": "^1.9"
1717
},
1818
"extra": {
1919
"branch-alias": {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Indicates that the user has been denied access to the requested resource.
10+
*/
11+
final class AuthorizationErrorException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Can't perform multiple operations on a tag simultaneously. Perform the operations sequentially.
10+
*/
11+
final class ConcurrentAccessException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Exception error indicating endpoint disabled.
10+
*/
11+
final class EndpointDisabledException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Indicates that the number of filter polices in your AWS account exceeds the limit. To add more filter polices, submit
10+
* an SNS Limit Increase case in the AWS Support Center.
11+
*/
12+
final class FilterPolicyLimitExceededException extends ClientException
13+
{
14+
protected function populateResult(ResponseInterface $response): void
15+
{
16+
$data = new \SimpleXMLElement($response->getContent(false));
17+
if (0 < $data->Error->count()) {
18+
$data = $data->Error;
19+
}
20+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
21+
$this->message = $v;
22+
}
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ServerException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Indicates an internal service error.
10+
*/
11+
final class InternalErrorException extends ServerException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Indicates that a request parameter does not comply with the associated constraints.
10+
*/
11+
final class InvalidParameterException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* Indicates that a request parameter does not comply with the associated constraints.
10+
*/
11+
final class InvalidParameterValueException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace AsyncAws\Sns\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use Symfony\Contracts\HttpClient\ResponseInterface;
7+
8+
/**
9+
* The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using Signature Version 4.
10+
*/
11+
final class InvalidSecurityException extends ClientException
12+
{
13+
protected function populateResult(ResponseInterface $response): void
14+
{
15+
$data = new \SimpleXMLElement($response->getContent(false));
16+
if (0 < $data->Error->count()) {
17+
$data = $data->Error;
18+
}
19+
if (null !== $v = (($v = $data->message) ? (string) $v : null)) {
20+
$this->message = $v;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)