vendor/doctrine/dbal/src/Driver/PDO/Exception.php line 28

  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\DBAL\Driver\PDO;
  4. use Doctrine\DBAL\Driver\AbstractException;
  5. use PDOException;
  6. /**
  7.  * @internal
  8.  *
  9.  * @psalm-immutable
  10.  */
  11. final class Exception extends AbstractException
  12. {
  13.     public static function new(PDOException $exception): self
  14.     {
  15.         if ($exception->errorInfo !== null) {
  16.             [$sqlState$code] = $exception->errorInfo;
  17.             $code ??= 0;
  18.         } else {
  19.             $code     $exception->getCode();
  20.             $sqlState null;
  21.         }
  22.         return new self($exception->getMessage(), $sqlState$code$exception);
  23.     }
  24. }