HttpException.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. /*
  8. * This file is part of the overtrue/wechat.
  9. *
  10. * (c) overtrue <i@overtrue.me>
  11. *
  12. * This source file is subject to the MIT license that is bundled
  13. * with this source code in the file LICENSE.
  14. */
  15. namespace ByteDance\Kernel\Exceptions;
  16. use Psr\Http\Message\ResponseInterface;
  17. /**
  18. * Class HttpException.
  19. *
  20. * @author overtrue <i@overtrue.me>
  21. */
  22. class HttpException extends Exception
  23. {
  24. /**
  25. * @var \Psr\Http\Message\ResponseInterface|null
  26. */
  27. public $response;
  28. /**
  29. * @var \Psr\Http\Message\ResponseInterface|\ByteDance\Kernel\Support\Collection|array|object|string
  30. */
  31. public $formattedResponse;
  32. /**
  33. * HttpException constructor.
  34. *
  35. * @param string $message
  36. * @param \Psr\Http\Message\ResponseInterface|null $response
  37. * @param null $formattedResponse
  38. * @param int|null $code
  39. */
  40. public function __construct($message, ResponseInterface $response = null, $formattedResponse = null, $code = null)
  41. {
  42. parent::__construct($message, $code);
  43. $this->response = $response;
  44. $this->formattedResponse = $formattedResponse;
  45. if ($response) {
  46. $response->getBody()->rewind();
  47. }
  48. }
  49. }