Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\OptimisticLockException;
use GraphQL\GraphQL;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerHelper;
Expand Down Expand Up @@ -592,6 +593,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode): voi
SerializerExceptionInterface::class => Response::HTTP_BAD_REQUEST,
InvalidArgumentException::class => Response::HTTP_BAD_REQUEST,
OptimisticLockException::class => Response::HTTP_CONFLICT,
UniqueConstraintViolationException::class => Response::HTTP_UNPROCESSABLE_ENTITY,
])
->info('The list of exceptions mapped to their HTTP status code.')
->normalizeKeys(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Symfony\Bundle\DependencyInjection\Configuration;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\OptimisticLockException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -101,6 +102,7 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm
ExceptionInterface::class => Response::HTTP_BAD_REQUEST,
InvalidArgumentException::class => Response::HTTP_BAD_REQUEST,
OptimisticLockException::class => Response::HTTP_CONFLICT,
UniqueConstraintViolationException::class => Response::HTTP_UNPROCESSABLE_ENTITY,
],
'path_segment_name_generator' => 'api_platform.metadata.path_segment_name_generator.underscore',
'inflector' => 'api_platform.metadata.inflector',
Expand Down
Loading