diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/dbal/src/Driver/API/PostgreSQL | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/API/PostgreSQL')
| -rw-r--r-- | vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php new file mode 100644 index 0000000..54e4966 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Driver\API\PostgreSQL; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface; | ||
| 8 | use Doctrine\DBAL\Driver\Exception; | ||
| 9 | use Doctrine\DBAL\Exception\ConnectionException; | ||
| 10 | use Doctrine\DBAL\Exception\DatabaseDoesNotExist; | ||
| 11 | use Doctrine\DBAL\Exception\DeadlockException; | ||
| 12 | use Doctrine\DBAL\Exception\DriverException; | ||
| 13 | use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; | ||
| 14 | use Doctrine\DBAL\Exception\InvalidFieldNameException; | ||
| 15 | use Doctrine\DBAL\Exception\NonUniqueFieldNameException; | ||
| 16 | use Doctrine\DBAL\Exception\NotNullConstraintViolationException; | ||
| 17 | use Doctrine\DBAL\Exception\SchemaDoesNotExist; | ||
| 18 | use Doctrine\DBAL\Exception\SyntaxErrorException; | ||
| 19 | use Doctrine\DBAL\Exception\TableExistsException; | ||
| 20 | use Doctrine\DBAL\Exception\TableNotFoundException; | ||
| 21 | use Doctrine\DBAL\Exception\UniqueConstraintViolationException; | ||
| 22 | use Doctrine\DBAL\Query; | ||
| 23 | |||
| 24 | use function str_contains; | ||
| 25 | |||
| 26 | /** @internal */ | ||
| 27 | final class ExceptionConverter implements ExceptionConverterInterface | ||
| 28 | { | ||
| 29 | /** @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html */ | ||
| 30 | public function convert(Exception $exception, ?Query $query): DriverException | ||
| 31 | { | ||
| 32 | switch ($exception->getSQLState()) { | ||
| 33 | case '40001': | ||
| 34 | case '40P01': | ||
| 35 | return new DeadlockException($exception, $query); | ||
| 36 | |||
| 37 | case '0A000': | ||
| 38 | // Foreign key constraint violations during a TRUNCATE operation | ||
| 39 | // are considered "feature not supported" in PostgreSQL. | ||
| 40 | if (str_contains($exception->getMessage(), 'truncate')) { | ||
| 41 | return new ForeignKeyConstraintViolationException($exception, $query); | ||
| 42 | } | ||
| 43 | |||
| 44 | break; | ||
| 45 | |||
| 46 | case '23502': | ||
| 47 | return new NotNullConstraintViolationException($exception, $query); | ||
| 48 | |||
| 49 | case '23503': | ||
| 50 | return new ForeignKeyConstraintViolationException($exception, $query); | ||
| 51 | |||
| 52 | case '23505': | ||
| 53 | return new UniqueConstraintViolationException($exception, $query); | ||
| 54 | |||
| 55 | case '3D000': | ||
| 56 | return new DatabaseDoesNotExist($exception, $query); | ||
| 57 | |||
| 58 | case '3F000': | ||
| 59 | return new SchemaDoesNotExist($exception, $query); | ||
| 60 | |||
| 61 | case '42601': | ||
| 62 | return new SyntaxErrorException($exception, $query); | ||
| 63 | |||
| 64 | case '42702': | ||
| 65 | return new NonUniqueFieldNameException($exception, $query); | ||
| 66 | |||
| 67 | case '42703': | ||
| 68 | return new InvalidFieldNameException($exception, $query); | ||
| 69 | |||
| 70 | case '42P01': | ||
| 71 | return new TableNotFoundException($exception, $query); | ||
| 72 | |||
| 73 | case '42P07': | ||
| 74 | return new TableExistsException($exception, $query); | ||
| 75 | |||
| 76 | case '08006': | ||
| 77 | return new ConnectionException($exception, $query); | ||
| 78 | } | ||
| 79 | |||
| 80 | return new DriverException($exception, $query); | ||
| 81 | } | ||
| 82 | } | ||
