diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php')
-rw-r--r-- | vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php | 94 |
1 files changed, 94 insertions, 0 deletions
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 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\DBAL\Driver\API\MySQL; | ||
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\ConnectionLost; | ||
11 | use Doctrine\DBAL\Exception\DatabaseDoesNotExist; | ||
12 | use Doctrine\DBAL\Exception\DeadlockException; | ||
13 | use Doctrine\DBAL\Exception\DriverException; | ||
14 | use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; | ||
15 | use Doctrine\DBAL\Exception\InvalidFieldNameException; | ||
16 | use Doctrine\DBAL\Exception\LockWaitTimeoutException; | ||
17 | use Doctrine\DBAL\Exception\NonUniqueFieldNameException; | ||
18 | use Doctrine\DBAL\Exception\NotNullConstraintViolationException; | ||
19 | use Doctrine\DBAL\Exception\SyntaxErrorException; | ||
20 | use Doctrine\DBAL\Exception\TableExistsException; | ||
21 | use Doctrine\DBAL\Exception\TableNotFoundException; | ||
22 | use Doctrine\DBAL\Exception\UniqueConstraintViolationException; | ||
23 | use Doctrine\DBAL\Query; | ||
24 | |||
25 | /** @internal */ | ||
26 | final 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 | } | ||