HttpException.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2021 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace think\exception;
  13. use Exception;
  14. /**
  15. * HTTP异常
  16. */
  17. class HttpException extends \RuntimeException
  18. {
  19. private $statusCode;
  20. private $headers;
  21. public function __construct(int $statusCode, string $message = '', Exception $previous = null, array $headers = [], $code = 0)
  22. {
  23. $this->statusCode = $statusCode;
  24. $this->headers = $headers;
  25. parent::__construct($message, $code, $previous);
  26. }
  27. public function getStatusCode()
  28. {
  29. return $this->statusCode;
  30. }
  31. public function getHeaders()
  32. {
  33. return $this->headers;
  34. }
  35. }