Exception.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Library for ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2021 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 仓库地址 :https://gitee.com/zoujingli/ThinkLibrary
  12. // | github 仓库地址 :https://github.com/zoujingli/ThinkLibrary
  13. // +----------------------------------------------------------------------
  14. namespace think\admin;
  15. /**
  16. * 自定义数据异常
  17. * Class Exception
  18. * @package think\admin
  19. */
  20. class Exception extends \Exception
  21. {
  22. /**
  23. * 异常数据对象
  24. * @var mixed
  25. */
  26. protected $data = [];
  27. /**
  28. * Exception constructor.
  29. * @param string $message
  30. * @param integer $code
  31. * @param mixed $data
  32. */
  33. public function __construct($message = "", $code = 0, $data = [])
  34. {
  35. $this->data = $data;
  36. $this->code = $code;
  37. $this->message = $message;
  38. parent::__construct($message, $code);
  39. }
  40. /**
  41. * 获取异常停止数据
  42. * @return mixed
  43. */
  44. public function getData()
  45. {
  46. return $this->data;
  47. }
  48. /**
  49. * 设置异常停止数据
  50. * @param mixed $data
  51. */
  52. public function setData($data)
  53. {
  54. $this->data = $data;
  55. }
  56. }