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/SQLite/ExceptionConverter.php | |
| 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/SQLite/ExceptionConverter.php')
| -rw-r--r-- | vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php new file mode 100644 index 0000000..5885195 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Driver\API\SQLite; | ||
| 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\DriverException; | ||
| 11 | use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; | ||
| 12 | use Doctrine\DBAL\Exception\InvalidFieldNameException; | ||
| 13 | use Doctrine\DBAL\Exception\LockWaitTimeoutException; | ||
| 14 | use Doctrine\DBAL\Exception\NonUniqueFieldNameException; | ||
| 15 | use Doctrine\DBAL\Exception\NotNullConstraintViolationException; | ||
| 16 | use Doctrine\DBAL\Exception\ReadOnlyException; | ||
| 17 | use Doctrine\DBAL\Exception\SyntaxErrorException; | ||
| 18 | use Doctrine\DBAL\Exception\TableExistsException; | ||
| 19 | use Doctrine\DBAL\Exception\TableNotFoundException; | ||
| 20 | use Doctrine\DBAL\Exception\UniqueConstraintViolationException; | ||
| 21 | use Doctrine\DBAL\Query; | ||
| 22 | |||
| 23 | use function str_contains; | ||
| 24 | |||
| 25 | /** @internal */ | ||
| 26 | final class ExceptionConverter implements ExceptionConverterInterface | ||
| 27 | { | ||
| 28 | /** @link http://www.sqlite.org/c3ref/c_abort.html */ | ||
| 29 | public function convert(Exception $exception, ?Query $query): DriverException | ||
| 30 | { | ||
| 31 | if (str_contains($exception->getMessage(), 'database is locked')) { | ||
| 32 | return new LockWaitTimeoutException($exception, $query); | ||
| 33 | } | ||
| 34 | |||
| 35 | if ( | ||
| 36 | str_contains($exception->getMessage(), 'must be unique') || | ||
| 37 | str_contains($exception->getMessage(), 'is not unique') || | ||
| 38 | str_contains($exception->getMessage(), 'are not unique') || | ||
| 39 | str_contains($exception->getMessage(), 'UNIQUE constraint failed') | ||
| 40 | ) { | ||
| 41 | return new UniqueConstraintViolationException($exception, $query); | ||
| 42 | } | ||
| 43 | |||
| 44 | if ( | ||
| 45 | str_contains($exception->getMessage(), 'may not be NULL') || | ||
| 46 | str_contains($exception->getMessage(), 'NOT NULL constraint failed') | ||
| 47 | ) { | ||
| 48 | return new NotNullConstraintViolationException($exception, $query); | ||
| 49 | } | ||
| 50 | |||
| 51 | if (str_contains($exception->getMessage(), 'no such table:')) { | ||
| 52 | return new TableNotFoundException($exception, $query); | ||
| 53 | } | ||
| 54 | |||
| 55 | if (str_contains($exception->getMessage(), 'already exists')) { | ||
| 56 | return new TableExistsException($exception, $query); | ||
| 57 | } | ||
| 58 | |||
| 59 | if (str_contains($exception->getMessage(), 'has no column named')) { | ||
| 60 | return new InvalidFieldNameException($exception, $query); | ||
| 61 | } | ||
| 62 | |||
| 63 | if (str_contains($exception->getMessage(), 'ambiguous column name')) { | ||
| 64 | return new NonUniqueFieldNameException($exception, $query); | ||
| 65 | } | ||
| 66 | |||
| 67 | if (str_contains($exception->getMessage(), 'syntax error')) { | ||
| 68 | return new SyntaxErrorException($exception, $query); | ||
| 69 | } | ||
| 70 | |||
| 71 | if (str_contains($exception->getMessage(), 'attempt to write a readonly database')) { | ||
| 72 | return new ReadOnlyException($exception, $query); | ||
| 73 | } | ||
| 74 | |||
| 75 | if (str_contains($exception->getMessage(), 'unable to open database file')) { | ||
| 76 | return new ConnectionException($exception, $query); | ||
| 77 | } | ||
| 78 | |||
| 79 | if (str_contains($exception->getMessage(), 'FOREIGN KEY constraint failed')) { | ||
| 80 | return new ForeignKeyConstraintViolationException($exception, $query); | ||
| 81 | } | ||
| 82 | |||
| 83 | return new DriverException($exception, $query); | ||
| 84 | } | ||
| 85 | } | ||
