TransportException.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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\Notifier\Exception;
  11. use Symfony\Contracts\HttpClient\ResponseInterface;
  12. /**
  13. * @author Fabien Potencier <fabien@symfony.com>
  14. *
  15. * @experimental in 5.1
  16. */
  17. class TransportException extends RuntimeException implements TransportExceptionInterface
  18. {
  19. private $response;
  20. private $debug = '';
  21. public function __construct(string $message, ResponseInterface $response, int $code = 0, \Exception $previous = null)
  22. {
  23. $this->response = $response;
  24. $this->debug .= $response->getInfo('debug') ?? '';
  25. parent::__construct($message, $code, $previous);
  26. }
  27. public function getResponse(): ResponseInterface
  28. {
  29. return $this->response;
  30. }
  31. public function getDebug(): string
  32. {
  33. return $this->debug;
  34. }
  35. }