AbstractDriverException.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Doctrine\DBAL\Driver;
  3. use Exception;
  4. /**
  5. * Abstract base implementation of the {@link DriverException} interface.
  6. */
  7. abstract class AbstractDriverException extends Exception implements DriverException
  8. {
  9. /**
  10. * The driver specific error code.
  11. *
  12. * @var int|string|null
  13. */
  14. private $errorCode;
  15. /**
  16. * The SQLSTATE of the driver.
  17. *
  18. * @var string|null
  19. */
  20. private $sqlState;
  21. /**
  22. * @param string $message The driver error message.
  23. * @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
  24. * @param int|string|null $errorCode The driver specific error code if any.
  25. */
  26. public function __construct($message, $sqlState = null, $errorCode = null)
  27. {
  28. parent::__construct($message);
  29. $this->errorCode = $errorCode;
  30. $this->sqlState = $sqlState;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function getErrorCode()
  36. {
  37. return $this->errorCode;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function getSQLState()
  43. {
  44. return $this->sqlState;
  45. }
  46. }