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.

62 lines
1.5 KiB

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Exception;
  11. /**
  12. * HttpException.
  13. *
  14. * @author Kris Wallsmith <kris@symfony.com>
  15. */
  16. class HttpException extends \RuntimeException implements HttpExceptionInterface
  17. {
  18. private $statusCode;
  19. private $headers;
  20. public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0)
  21. {
  22. if (null === $message) {
  23. trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $message to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
  24. $message = '';
  25. }
  26. if (null === $code) {
  27. trigger_deprecation('symfony/http-kernel', '5.3', 'Passing null as $code to "%s()" is deprecated, pass 0 instead.', __METHOD__);
  28. $code = 0;
  29. }
  30. $this->statusCode = $statusCode;
  31. $this->headers = $headers;
  32. parent::__construct($message, $code, $previous);
  33. }
  34. public function getStatusCode()
  35. {
  36. return $this->statusCode;
  37. }
  38. public function getHeaders()
  39. {
  40. return $this->headers;
  41. }
  42. /**
  43. * Set response headers.
  44. *
  45. * @param array $headers Response headers
  46. */
  47. public function setHeaders(array $headers)
  48. {
  49. $this->headers = $headers;
  50. }
  51. }