ErrorException.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2019 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. declare (strict_types = 1);
  12. namespace think\exception;
  13. use think\Exception;
  14. /**
  15. * ThinkPHP错误异常
  16. * 主要用于封装 set_error_handler 和 register_shutdown_function 得到的错误
  17. * 除开从 think\Exception 继承的功能
  18. * 其他和PHP系统\ErrorException功能基本一样
  19. */
  20. class ErrorException extends Exception
  21. {
  22. /**
  23. * 用于保存错误级别
  24. * @var integer
  25. */
  26. protected $severity;
  27. /**
  28. * 错误异常构造函数
  29. * @access public
  30. * @param integer $severity 错误级别
  31. * @param string $message 错误详细信息
  32. * @param string $file 出错文件路径
  33. * @param integer $line 出错行号
  34. */
  35. public function __construct(int $severity, string $message, string $file, int $line)
  36. {
  37. $this->severity = $severity;
  38. $this->message = $message;
  39. $this->file = $file;
  40. $this->line = $line;
  41. $this->code = 0;
  42. }
  43. /**
  44. * 获取错误级别
  45. * @access public
  46. * @return integer 错误级别
  47. */
  48. final public function getSeverity()
  49. {
  50. return $this->severity;
  51. }
  52. }