1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\DBAL\Driver; |
4
|
|
|
|
5
|
|
|
use Exception; |
6
|
|
|
use Throwable; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* A driver exception. |
10
|
|
|
* |
11
|
|
|
* Driver exceptions provide the SQLSTATE of the driver |
12
|
|
|
* and the driver specific error code at the time the error occurred. |
13
|
|
|
*/ |
14
|
|
|
class DriverException extends Exception |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The driver specific error code. |
18
|
|
|
* |
19
|
|
|
* @var int|string|null |
20
|
|
|
*/ |
21
|
|
|
private $errorCode; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The SQLSTATE of the driver. |
25
|
|
|
* |
26
|
|
|
* @var string|null |
27
|
|
|
*/ |
28
|
|
|
private $sqlState; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param string $message The driver error message. |
32
|
|
|
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any. |
33
|
|
|
* @param int|string|null $errorCode The driver specific error code if any. |
34
|
|
|
* @param Throwable|null $previous The previous throwable used for the exception chaining. |
35
|
|
|
*/ |
36
|
3452 |
|
public function __construct(string $message, ?string $sqlState = null, $errorCode = null, ?Throwable $previous = null) |
37
|
|
|
{ |
38
|
3452 |
|
parent::__construct($message, 0, $previous); |
39
|
|
|
|
40
|
3452 |
|
$this->errorCode = $errorCode; |
41
|
3452 |
|
$this->sqlState = $sqlState; |
42
|
3452 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns the driver specific error code if available. |
46
|
|
|
* |
47
|
|
|
* Returns null if no driver specific error code is available |
48
|
|
|
* for the error raised by the driver. |
49
|
|
|
* |
50
|
|
|
* @return int|string|null The error code. |
51
|
|
|
*/ |
52
|
1988 |
|
public function getErrorCode() |
53
|
|
|
{ |
54
|
1988 |
|
return $this->errorCode; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns the SQLSTATE the driver was in at the time the error occurred. |
59
|
|
|
* |
60
|
|
|
* Returns null if the driver does not provide a SQLSTATE for the error occurred. |
61
|
|
|
* |
62
|
|
|
* @return string|null The SQLSTATE, or null if not available. |
63
|
|
|
*/ |
64
|
1138 |
|
public function getSQLState() : ?string |
65
|
|
|
{ |
66
|
1138 |
|
return $this->sqlState; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|