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

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

5 6 7 8 9
namespace Doctrine\DBAL\Driver;

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

        parent::__construct($exception->getMessage(), $sqlState, $code, $exception);
25 26
    }
}