summaryrefslogtreecommitdiff
path: root/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php')
-rw-r--r--vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php49
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
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}