| Total Complexity | 3 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class PDOException extends AbstractDriverException |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The driver specific error code. |
||
| 16 | * |
||
| 17 | * @var int|string|null |
||
| 18 | */ |
||
| 19 | private $errorCode; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The SQLSTATE of the driver. |
||
| 23 | * |
||
| 24 | * @var string|null |
||
| 25 | */ |
||
| 26 | private $sqlState; |
||
| 27 | |||
| 28 | public static function fromPDOException(\PDOException $exception) |
||
| 29 | { |
||
| 30 | $e = new self( |
||
| 31 | $exception->getMessage(), |
||
| 32 | $exception->errorInfo[0] ?? $exception->getCode(), |
||
| 33 | $exception->errorInfo[1] ?? $exception->getCode() |
||
| 34 | ); |
||
| 35 | |||
| 36 | $e->code = $exception->getCode(); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | public function getErrorCode() |
||
| 43 | { |
||
| 44 | return $this->errorCode; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | public function getSQLState() |
||
| 53 | } |
||
| 54 | } |
||
| 55 |