| Conditions | 5 |
| Paths | 6 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function __construct(string $message, ?\Throwable $previous = null) |
||
| 14 | { |
||
| 15 | $code = self::CODE; |
||
| 16 | |||
| 17 | switch (true) { |
||
| 18 | case $previous instanceof \PDOException: |
||
| 19 | if (!empty($previous->errorInfo[1])) { |
||
| 20 | $code = $previous->errorInfo[1]; |
||
| 21 | $this->sqlState = $previous->errorInfo[0]; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!empty($previous->errorInfo[2])) { |
||
| 25 | // cleaner error message without all the codes. |
||
| 26 | $message = $previous->errorInfo[2]; |
||
| 27 | } |
||
| 28 | break; |
||
| 29 | case $previous instanceof self: |
||
| 30 | // A \PDOException that was re-thrown |
||
| 31 | $code = $previous->getCode(); |
||
| 32 | $this->sqlState = $previous->getSqlState(); |
||
| 33 | break; |
||
| 34 | default: |
||
| 35 | break; |
||
| 36 | } |
||
| 37 | |||
| 38 | parent::__construct($message, $code, $previous); |
||
| 39 | } |
||
| 46 |