| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace Doctrine\DBAL\Driver\API\IBMDB2;
|
|
|
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\NonUniqueFieldNameException;
|
|
|
14 |
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
|
|
15 |
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
|
|
16 |
use Doctrine\DBAL\Exception\TableExistsException;
|
|
|
17 |
use Doctrine\DBAL\Exception\TableNotFoundException;
|
|
|
18 |
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|
|
19 |
use Doctrine\DBAL\Query;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* @internal
|
|
|
23 |
*
|
|
|
24 |
* @link https://www.ibm.com/docs/en/db2/11.5?topic=messages-sql
|
|
|
25 |
*/
|
|
|
26 |
final class ExceptionConverter implements ExceptionConverterInterface
|
|
|
27 |
{
|
|
|
28 |
public function convert(Exception $exception, ?Query $query): DriverException
|
|
|
29 |
{
|
|
|
30 |
switch ($exception->getCode()) {
|
|
|
31 |
case -104:
|
|
|
32 |
return new SyntaxErrorException($exception, $query);
|
|
|
33 |
|
|
|
34 |
case -203:
|
|
|
35 |
return new NonUniqueFieldNameException($exception, $query);
|
|
|
36 |
|
|
|
37 |
case -204:
|
|
|
38 |
return new TableNotFoundException($exception, $query);
|
|
|
39 |
|
|
|
40 |
case -206:
|
|
|
41 |
return new InvalidFieldNameException($exception, $query);
|
|
|
42 |
|
|
|
43 |
case -407:
|
|
|
44 |
return new NotNullConstraintViolationException($exception, $query);
|
|
|
45 |
|
|
|
46 |
case -530:
|
|
|
47 |
case -531:
|
|
|
48 |
case -532:
|
|
|
49 |
case -20356:
|
|
|
50 |
return new ForeignKeyConstraintViolationException($exception, $query);
|
|
|
51 |
|
|
|
52 |
case -601:
|
|
|
53 |
return new TableExistsException($exception, $query);
|
|
|
54 |
|
|
|
55 |
case -803:
|
|
|
56 |
return new UniqueConstraintViolationException($exception, $query);
|
|
|
57 |
|
|
|
58 |
case -1336:
|
|
|
59 |
case -30082:
|
|
|
60 |
return new ConnectionException($exception, $query);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
return new DriverException($exception, $query);
|
|
|
64 |
}
|
|
|
65 |
}
|