summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Driver/API
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2024-08-13 23:45:21 +0200
committerpolo <ordipolo@gmx.fr>2024-08-13 23:45:21 +0200
commitbf6655a534a6775d30cafa67bd801276bda1d98d (patch)
treec6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/dbal/src/Driver/API
parent94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff)
downloadAppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/API')
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php25
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php47
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php94
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php52
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php82
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php49
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php85
7 files changed, 434 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php
new file mode 100644
index 0000000..a7bf271
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php
@@ -0,0 +1,25 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API;
6
7use Doctrine\DBAL\Driver\Exception;
8use Doctrine\DBAL\Exception\DriverException;
9use Doctrine\DBAL\Query;
10
11interface ExceptionConverter
12{
13 /**
14 * Converts a given driver-level exception into a DBAL-level driver exception.
15 *
16 * Implementors should use the vendor-specific error code and SQLSTATE of the exception
17 * and instantiate the most appropriate specialized {@see DriverException} subclass.
18 *
19 * @param Exception $exception The driver exception to convert.
20 * @param Query|null $query The SQL query that triggered the exception, if any.
21 *
22 * @return DriverException An instance of {@see DriverException} or one of its subclasses.
23 */
24 public function convert(Exception $exception, ?Query $query): DriverException;
25}
diff --git a/vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php
new file mode 100644
index 0000000..bcd5554
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php
@@ -0,0 +1,47 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API\IBMDB2;
6
7use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
8use Doctrine\DBAL\Driver\Exception;
9use Doctrine\DBAL\Exception\ConnectionException;
10use Doctrine\DBAL\Exception\DriverException;
11use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
12use Doctrine\DBAL\Exception\InvalidFieldNameException;
13use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
14use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
15use Doctrine\DBAL\Exception\SyntaxErrorException;
16use Doctrine\DBAL\Exception\TableExistsException;
17use Doctrine\DBAL\Exception\TableNotFoundException;
18use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
19use Doctrine\DBAL\Query;
20
21/**
22 * @internal
23 *
24 * @link https://www.ibm.com/docs/en/db2/11.5?topic=messages-sql
25 */
26final class ExceptionConverter implements ExceptionConverterInterface
27{
28 public function convert(Exception $exception, ?Query $query): DriverException
29 {
30 return match ($exception->getCode()) {
31 -104 => new SyntaxErrorException($exception, $query),
32 -203 => new NonUniqueFieldNameException($exception, $query),
33 -204 => new TableNotFoundException($exception, $query),
34 -206 => new InvalidFieldNameException($exception, $query),
35 -407 => new NotNullConstraintViolationException($exception, $query),
36 -530,
37 -531,
38 -532,
39 -20356 => new ForeignKeyConstraintViolationException($exception, $query),
40 -601 => new TableExistsException($exception, $query),
41 -803 => new UniqueConstraintViolationException($exception, $query),
42 -1336,
43 -30082 => new ConnectionException($exception, $query),
44 default => new DriverException($exception, $query),
45 };
46 }
47}
diff --git a/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php
new file mode 100644
index 0000000..ad0f0e1
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php
@@ -0,0 +1,94 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API\MySQL;
6
7use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
8use Doctrine\DBAL\Driver\Exception;
9use Doctrine\DBAL\Exception\ConnectionException;
10use Doctrine\DBAL\Exception\ConnectionLost;
11use Doctrine\DBAL\Exception\DatabaseDoesNotExist;
12use Doctrine\DBAL\Exception\DeadlockException;
13use Doctrine\DBAL\Exception\DriverException;
14use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
15use Doctrine\DBAL\Exception\InvalidFieldNameException;
16use Doctrine\DBAL\Exception\LockWaitTimeoutException;
17use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
18use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
19use Doctrine\DBAL\Exception\SyntaxErrorException;
20use Doctrine\DBAL\Exception\TableExistsException;
21use Doctrine\DBAL\Exception\TableNotFoundException;
22use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
23use Doctrine\DBAL\Query;
24
25/** @internal */
26final class ExceptionConverter implements ExceptionConverterInterface
27{
28 /**
29 * @link https://dev.mysql.com/doc/mysql-errors/8.0/en/client-error-reference.html
30 * @link https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html
31 */
32 public function convert(Exception $exception, ?Query $query): DriverException
33 {
34 return match ($exception->getCode()) {
35 1008 => new DatabaseDoesNotExist($exception, $query),
36 1213 => new DeadlockException($exception, $query),
37 1205 => new LockWaitTimeoutException($exception, $query),
38 1050 => new TableExistsException($exception, $query),
39 1051,
40 1146 => new TableNotFoundException($exception, $query),
41 1216,
42 1217,
43 1451,
44 1452,
45 1701 => new ForeignKeyConstraintViolationException($exception, $query),
46 1062,
47 1557,
48 1569,
49 1586 => new UniqueConstraintViolationException($exception, $query),
50 1054,
51 1166,
52 1611 => new InvalidFieldNameException($exception, $query),
53 1052,
54 1060,
55 1110 => new NonUniqueFieldNameException($exception, $query),
56 1064,
57 1149,
58 1287,
59 1341,
60 1342,
61 1343,
62 1344,
63 1382,
64 1479,
65 1541,
66 1554,
67 1626 => new SyntaxErrorException($exception, $query),
68 1044,
69 1045,
70 1046,
71 1049,
72 1095,
73 1142,
74 1143,
75 1227,
76 1370,
77 1429,
78 2002,
79 2005,
80 2054 => new ConnectionException($exception, $query),
81 2006,
82 4031 => new ConnectionLost($exception, $query),
83 1048,
84 1121,
85 1138,
86 1171,
87 1252,
88 1263,
89 1364,
90 1566 => new NotNullConstraintViolationException($exception, $query),
91 default => new DriverException($exception, $query),
92 };
93 }
94}
diff --git a/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php
new file mode 100644
index 0000000..1c0dc79
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php
@@ -0,0 +1,52 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API\OCI;
6
7use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
8use Doctrine\DBAL\Driver\Exception;
9use Doctrine\DBAL\Exception\ConnectionException;
10use Doctrine\DBAL\Exception\DatabaseDoesNotExist;
11use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
12use Doctrine\DBAL\Exception\DriverException;
13use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
14use Doctrine\DBAL\Exception\InvalidFieldNameException;
15use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
16use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
17use Doctrine\DBAL\Exception\SyntaxErrorException;
18use Doctrine\DBAL\Exception\TableExistsException;
19use Doctrine\DBAL\Exception\TableNotFoundException;
20use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
21use Doctrine\DBAL\Query;
22
23/** @internal */
24final class ExceptionConverter implements ExceptionConverterInterface
25{
26 /** @link http://www.dba-oracle.com/t_error_code_list.htm */
27 public function convert(Exception $exception, ?Query $query): DriverException
28 {
29 return match ($exception->getCode()) {
30 1,
31 2299,
32 38911 => new UniqueConstraintViolationException($exception, $query),
33 904 => new InvalidFieldNameException($exception, $query),
34 918,
35 960 => new NonUniqueFieldNameException($exception, $query),
36 923 => new SyntaxErrorException($exception, $query),
37 942 => new TableNotFoundException($exception, $query),
38 955 => new TableExistsException($exception, $query),
39 1017,
40 12545 => new ConnectionException($exception, $query),
41 1400 => new NotNullConstraintViolationException($exception, $query),
42 1918 => new DatabaseDoesNotExist($exception, $query),
43 2289,
44 2443,
45 4080 => new DatabaseObjectNotFoundException($exception, $query),
46 2266,
47 2291,
48 2292 => new ForeignKeyConstraintViolationException($exception, $query),
49 default => new DriverException($exception, $query),
50 };
51 }
52}
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
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API\PostgreSQL;
6
7use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
8use Doctrine\DBAL\Driver\Exception;
9use Doctrine\DBAL\Exception\ConnectionException;
10use Doctrine\DBAL\Exception\DatabaseDoesNotExist;
11use Doctrine\DBAL\Exception\DeadlockException;
12use Doctrine\DBAL\Exception\DriverException;
13use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
14use Doctrine\DBAL\Exception\InvalidFieldNameException;
15use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
16use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
17use Doctrine\DBAL\Exception\SchemaDoesNotExist;
18use Doctrine\DBAL\Exception\SyntaxErrorException;
19use Doctrine\DBAL\Exception\TableExistsException;
20use Doctrine\DBAL\Exception\TableNotFoundException;
21use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
22use Doctrine\DBAL\Query;
23
24use function str_contains;
25
26/** @internal */
27final 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}
diff --git a/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
new file mode 100644
index 0000000..561e58b
--- /dev/null
+++ b/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
@@ -0,0 +1,49 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API\SQLSrv;
6
7use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
8use Doctrine\DBAL\Driver\Exception;
9use Doctrine\DBAL\Exception\ConnectionException;
10use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
11use Doctrine\DBAL\Exception\DriverException;
12use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
13use Doctrine\DBAL\Exception\InvalidFieldNameException;
14use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
15use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
16use Doctrine\DBAL\Exception\SyntaxErrorException;
17use Doctrine\DBAL\Exception\TableExistsException;
18use Doctrine\DBAL\Exception\TableNotFoundException;
19use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
20use Doctrine\DBAL\Query;
21
22/**
23 * @internal
24 *
25 * @link https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors
26 */
27final class ExceptionConverter implements ExceptionConverterInterface
28{
29 public function convert(Exception $exception, ?Query $query): DriverException
30 {
31 return match ($exception->getCode()) {
32 102 => new SyntaxErrorException($exception, $query),
33 207 => new InvalidFieldNameException($exception, $query),
34 208 => new TableNotFoundException($exception, $query),
35 209 => new NonUniqueFieldNameException($exception, $query),
36 515 => new NotNullConstraintViolationException($exception, $query),
37 547,
38 4712 => new ForeignKeyConstraintViolationException($exception, $query),
39 2601,
40 2627 => new UniqueConstraintViolationException($exception, $query),
41 2714 => new TableExistsException($exception, $query),
42 3701,
43 15151 => new DatabaseObjectNotFoundException($exception, $query),
44 11001,
45 18456 => new ConnectionException($exception, $query),
46 default => new DriverException($exception, $query),
47 };
48 }
49}
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
3declare(strict_types=1);
4
5namespace Doctrine\DBAL\Driver\API\SQLite;
6
7use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
8use Doctrine\DBAL\Driver\Exception;
9use Doctrine\DBAL\Exception\ConnectionException;
10use Doctrine\DBAL\Exception\DriverException;
11use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
12use Doctrine\DBAL\Exception\InvalidFieldNameException;
13use Doctrine\DBAL\Exception\LockWaitTimeoutException;
14use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
15use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
16use Doctrine\DBAL\Exception\ReadOnlyException;
17use Doctrine\DBAL\Exception\SyntaxErrorException;
18use Doctrine\DBAL\Exception\TableExistsException;
19use Doctrine\DBAL\Exception\TableNotFoundException;
20use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
21use Doctrine\DBAL\Query;
22
23use function str_contains;
24
25/** @internal */
26final 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}