You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.6 KiB

  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://zjzit.cn>
  10. // +----------------------------------------------------------------------
  11. namespace think;
  12. class Exception extends \Exception
  13. {
  14. /**
  15. * @var array 保存异常页面显示的额外 Debug 数据
  16. */
  17. protected $data = [];
  18. /**
  19. * 设置异常额外的 Debug 数据
  20. * 数据将会显示为下面的格式
  21. *
  22. * Exception Data
  23. * --------------------------------------------------
  24. * Label 1
  25. * key1 value1
  26. * key2 value2
  27. * Label 2
  28. * key1 value1
  29. * key2 value2
  30. *
  31. * @access protected
  32. * @param string $label 数据分类,用于异常页面显示
  33. * @param array $data 需要显示的数据,必须为关联数组
  34. * @return void
  35. */
  36. final protected function setData($label, array $data)
  37. {
  38. $this->data[$label] = $data;
  39. }
  40. /**
  41. * 获取异常额外 Debug 数据
  42. * 主要用于输出到异常页面便于调试
  43. * @access public
  44. * @return array
  45. */
  46. final public function getData()
  47. {
  48. return $this->data;
  49. }
  50. }