PDOException.php 691 Bytes
Newer Older
1 2
<?php

Michael Moravec's avatar
Michael Moravec committed
3 4
declare(strict_types=1);

5 6 7 8
namespace Doctrine\DBAL\Driver;

/**
 * Tiny wrapper for PDOException instances to implement the {@link DriverException} interface.
9 10
 *
 * @psalm-immutable
11
 */
12
class PDOException extends AbstractDriverException
13 14 15 16 17 18
{
    /**
     * @param \PDOException $exception The PDO exception to wrap.
     */
    public function __construct(\PDOException $exception)
    {
19 20 21 22 23 24 25 26
        if ($exception->errorInfo !== null) {
            [$sqlState, $code] = $exception->errorInfo;
        } else {
            $code     = $exception->getCode();
            $sqlState = null;
        }

        parent::__construct($exception->getMessage(), $sqlState, $code, $exception);
27 28
    }
}