Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\db;
  8. /**
  9. * Exception represents an exception that is caused by some DB-related operations.
  10. *
  11. * @author Qiang Xue <qiang.xue@gmail.com>
  12. * @since 2.0
  13. */
  14. class Exception extends \yii\base\Exception
  15. {
  16. /**
  17. * @var array the error info provided by a PDO exception. This is the same as returned
  18. * by [PDO::errorInfo](http://www.php.net/manual/en/pdo.errorinfo.php).
  19. */
  20. public $errorInfo = [];
  21. /**
  22. * Constructor.
  23. * @param string $message PDO error message
  24. * @param array $errorInfo PDO error info
  25. * @param integer $code PDO error code
  26. * @param \Exception $previous The previous exception used for the exception chaining.
  27. */
  28. public function __construct($message, $errorInfo = [], $code = 0, \Exception $previous = null)
  29. {
  30. $this->errorInfo = $errorInfo;
  31. parent::__construct($message, $code, $previous);
  32. }
  33. /**
  34. * @return string the user-friendly name of this exception
  35. */
  36. public function getName()
  37. {
  38. return 'Database Exception';
  39. }
  40. /**
  41. * @return string readable representation of exception
  42. */
  43. public function __toString()
  44. {
  45. return parent::__toString() . PHP_EOL
  46. . 'Additional Information:' . PHP_EOL . print_r($this->errorInfo, true);
  47. }
  48. }