diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php')
-rw-r--r-- | vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php | 49 |
1 files changed, 49 insertions, 0 deletions
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 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\DBAL\Driver\API\SQLSrv; | ||
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\DatabaseObjectNotFoundException; | ||
11 | use Doctrine\DBAL\Exception\DriverException; | ||
12 | use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; | ||
13 | use Doctrine\DBAL\Exception\InvalidFieldNameException; | ||
14 | use Doctrine\DBAL\Exception\NonUniqueFieldNameException; | ||
15 | use Doctrine\DBAL\Exception\NotNullConstraintViolationException; | ||
16 | use Doctrine\DBAL\Exception\SyntaxErrorException; | ||
17 | use Doctrine\DBAL\Exception\TableExistsException; | ||
18 | use Doctrine\DBAL\Exception\TableNotFoundException; | ||
19 | use Doctrine\DBAL\Exception\UniqueConstraintViolationException; | ||
20 | use 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 | */ | ||
27 | final 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 | } | ||