| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace Doctrine\DBAL\Driver\API\OCI;
|
|
|
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\DatabaseDoesNotExist;
|
|
|
11 |
use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
|
|
|
12 |
use Doctrine\DBAL\Exception\DriverException;
|
|
|
13 |
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
|
|
14 |
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
|
|
15 |
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
|
|
16 |
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
|
|
17 |
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
|
|
18 |
use Doctrine\DBAL\Exception\TableExistsException;
|
|
|
19 |
use Doctrine\DBAL\Exception\TableNotFoundException;
|
|
|
20 |
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|
|
21 |
use Doctrine\DBAL\Query;
|
|
|
22 |
|
|
|
23 |
/** @internal */
|
|
|
24 |
final 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 |
switch ($exception->getCode()) {
|
|
|
30 |
case 1:
|
|
|
31 |
case 2299:
|
|
|
32 |
case 38911:
|
|
|
33 |
return new UniqueConstraintViolationException($exception, $query);
|
|
|
34 |
|
|
|
35 |
case 904:
|
|
|
36 |
return new InvalidFieldNameException($exception, $query);
|
|
|
37 |
|
|
|
38 |
case 918:
|
|
|
39 |
case 960:
|
|
|
40 |
return new NonUniqueFieldNameException($exception, $query);
|
|
|
41 |
|
|
|
42 |
case 923:
|
|
|
43 |
return new SyntaxErrorException($exception, $query);
|
|
|
44 |
|
|
|
45 |
case 942:
|
|
|
46 |
return new TableNotFoundException($exception, $query);
|
|
|
47 |
|
|
|
48 |
case 955:
|
|
|
49 |
return new TableExistsException($exception, $query);
|
|
|
50 |
|
|
|
51 |
case 1017:
|
|
|
52 |
case 12545:
|
|
|
53 |
return new ConnectionException($exception, $query);
|
|
|
54 |
|
|
|
55 |
case 1400:
|
|
|
56 |
return new NotNullConstraintViolationException($exception, $query);
|
|
|
57 |
|
|
|
58 |
case 1918:
|
|
|
59 |
return new DatabaseDoesNotExist($exception, $query);
|
|
|
60 |
|
|
|
61 |
case 2289:
|
|
|
62 |
case 2443:
|
|
|
63 |
case 4080:
|
|
|
64 |
return new DatabaseObjectNotFoundException($exception, $query);
|
|
|
65 |
|
|
|
66 |
case 2266:
|
|
|
67 |
case 2291:
|
|
|
68 |
case 2292:
|
|
|
69 |
return new ForeignKeyConstraintViolationException($exception, $query);
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
return new DriverException($exception, $query);
|
|
|
73 |
}
|
|
|
74 |
}
|