diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/dbal/src/Exception/DriverException.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/dbal/src/Exception/DriverException.php')
| -rw-r--r-- | vendor/doctrine/dbal/src/Exception/DriverException.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Exception/DriverException.php b/vendor/doctrine/dbal/src/Exception/DriverException.php new file mode 100644 index 0000000..d794d77 --- /dev/null +++ b/vendor/doctrine/dbal/src/Exception/DriverException.php | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Exception; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Driver; | ||
| 8 | use Doctrine\DBAL\Exception; | ||
| 9 | use Doctrine\DBAL\Query; | ||
| 10 | |||
| 11 | use function assert; | ||
| 12 | |||
| 13 | /** | ||
| 14 | * Base class for all errors detected in the driver. | ||
| 15 | * | ||
| 16 | * @psalm-immutable | ||
| 17 | */ | ||
| 18 | class DriverException extends \Exception implements Exception, Driver\Exception | ||
| 19 | { | ||
| 20 | /** | ||
| 21 | * @internal | ||
| 22 | * | ||
| 23 | * @param Driver\Exception $driverException The DBAL driver exception to chain. | ||
| 24 | * @param Query|null $query The SQL query that triggered the exception, if any. | ||
| 25 | */ | ||
| 26 | public function __construct( | ||
| 27 | Driver\Exception $driverException, | ||
| 28 | private readonly ?Query $query, | ||
| 29 | ) { | ||
| 30 | if ($query !== null) { | ||
| 31 | $message = 'An exception occurred while executing a query: ' . $driverException->getMessage(); | ||
| 32 | } else { | ||
| 33 | $message = 'An exception occurred in the driver: ' . $driverException->getMessage(); | ||
| 34 | } | ||
| 35 | |||
| 36 | parent::__construct($message, $driverException->getCode(), $driverException); | ||
| 37 | } | ||
| 38 | |||
| 39 | public function getSQLState(): ?string | ||
| 40 | { | ||
| 41 | $previous = $this->getPrevious(); | ||
| 42 | assert($previous instanceof Driver\Exception); | ||
| 43 | |||
| 44 | return $previous->getSQLState(); | ||
| 45 | } | ||
| 46 | |||
| 47 | public function getQuery(): ?Query | ||
| 48 | { | ||
| 49 | return $this->query; | ||
| 50 | } | ||
| 51 | } | ||
