Skip to content

Commit 3fcdb9c

Browse files
committed
API responses
1 parent 014611d commit 3fcdb9c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Common/EventListener/ExceptionListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Exception;
88
use PhpList\Core\Domain\Identity\Exception\AdminAttributeCreationException;
9+
use PhpList\Core\Domain\Subscription\Exception\AttributeDefinitionCreationException;
910
use PhpList\Core\Domain\Subscription\Exception\SubscriptionCreationException;
1011
use Symfony\Component\HttpFoundation\JsonResponse;
1112
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
@@ -42,6 +43,11 @@ public function onKernelException(ExceptionEvent $event): void
4243
'message' => $exception->getMessage(),
4344
], $exception->getStatusCode());
4445
$event->setResponse($response);
46+
} elseif ($exception instanceof AttributeDefinitionCreationException) {
47+
$response = new JsonResponse([
48+
'message' => $exception->getMessage(),
49+
], $exception->getStatusCode());
50+
$event->setResponse($response);
4551
} elseif ($exception instanceof ValidatorException) {
4652
$response = new JsonResponse([
4753
'message' => $exception->getMessage(),

src/Subscription/Controller/SubscriberAttributeDefinitionController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public function __construct(
7474
description: 'Failure',
7575
content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse')
7676
),
77+
new OA\Response(
78+
response: 409,
79+
description: 'Failure',
80+
content: new OA\JsonContent(ref: '#/components/schemas/AlreadyExistsResponse')
81+
),
7782
new OA\Response(
7883
response: 422,
7984
description: 'Failure',

0 commit comments

Comments
 (0)