| @@ 29-75 (lines=47) @@ | ||
| 26 | * @link www.doctrine-project.org |
|
| 27 | * @since 2.5 |
|
| 28 | */ |
|
| 29 | abstract class AbstractDriverException extends \Exception implements DriverException |
|
| 30 | { |
|
| 31 | /** |
|
| 32 | * The driver specific error code. |
|
| 33 | * |
|
| 34 | * @var integer|string|null |
|
| 35 | */ |
|
| 36 | private $errorCode; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * The SQLSTATE of the driver. |
|
| 40 | * |
|
| 41 | * @var string|null |
|
| 42 | */ |
|
| 43 | private $sqlState; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Constructor. |
|
| 47 | * |
|
| 48 | * @param string $message The driver error message. |
|
| 49 | * @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any. |
|
| 50 | * @param integer|string|null $errorCode The driver specific error code if any. |
|
| 51 | */ |
|
| 52 | public function __construct($message, $sqlState = null, $errorCode = null) |
|
| 53 | { |
|
| 54 | parent::__construct($message); |
|
| 55 | ||
| 56 | $this->errorCode = $errorCode; |
|
| 57 | $this->sqlState = $sqlState; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * {@inheritdoc} |
|
| 62 | */ |
|
| 63 | public function getErrorCode() |
|
| 64 | { |
|
| 65 | return $this->errorCode; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * {@inheritdoc} |
|
| 70 | */ |
|
| 71 | public function getSQLState() |
|
| 72 | { |
|
| 73 | return $this->sqlState; |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||
| @@ 224-261 (lines=38) @@ | ||
| 221 | ||
| 222 | foreach ($this->getExceptionConversionData() as $convertedExceptionClassName => $errors) { |
|
| 223 | foreach ($errors as $error) { |
|
| 224 | $driverException = new class ($error[0], $error[1], $error[2]) |
|
| 225 | extends \Exception |
|
| 226 | implements DriverException |
|
| 227 | { |
|
| 228 | /** |
|
| 229 | * @var mixed |
|
| 230 | */ |
|
| 231 | private $errorCode; |
|
| 232 | ||
| 233 | /** |
|
| 234 | * @var mixed |
|
| 235 | */ |
|
| 236 | private $sqlState; |
|
| 237 | ||
| 238 | public function __construct($errorCode, $sqlState, $message) |
|
| 239 | { |
|
| 240 | parent::__construct($message); |
|
| 241 | ||
| 242 | $this->errorCode = $errorCode; |
|
| 243 | $this->sqlState = $sqlState; |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * {@inheritDoc} |
|
| 248 | */ |
|
| 249 | public function getErrorCode() |
|
| 250 | { |
|
| 251 | return $this->errorCode; |
|
| 252 | } |
|
| 253 | ||
| 254 | /** |
|
| 255 | * {@inheritDoc} |
|
| 256 | */ |
|
| 257 | public function getSQLState() |
|
| 258 | { |
|
| 259 | return $this->sqlState; |
|
| 260 | } |
|
| 261 | }; |
|
| 262 | ||
| 263 | $data[] = array($driverException, $convertedExceptionClassName); |
|
| 264 | } |
|