AbstractDriverException.php 1.14 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Driver;

5 6
use Exception;

7 8 9
/**
 * Abstract base implementation of the {@link DriverException} interface.
 */
10
abstract class AbstractDriverException extends Exception implements DriverException
11 12 13 14
{
    /**
     * The driver specific error code.
     *
15
     * @var int|string|null
16 17 18 19 20 21 22 23 24 25 26
     */
    private $errorCode;

    /**
     * The SQLSTATE of the driver.
     *
     * @var string|null
     */
    private $sqlState;

    /**
27 28 29
     * @param string          $message   The driver error message.
     * @param string|null     $sqlState  The SQLSTATE the driver is in at the time the error occurred, if any.
     * @param int|string|null $errorCode The driver specific error code if any.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
     */
    public function __construct($message, $sqlState = null, $errorCode = null)
    {
        parent::__construct($message);

        $this->errorCode = $errorCode;
        $this->sqlState  = $sqlState;
    }

    /**
     * {@inheritdoc}
     */
    public function getErrorCode()
    {
        return $this->errorCode;
    }

    /**
     * {@inheritdoc}
     */
    public function getSQLState()
    {
        return $this->sqlState;
    }
}