HttpException.php
6 months ago
NetworkException.php
2 years ago
RequestException.php
6 months ago
TransferException.php
2 years ago
RequestException.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaHttp\Client\Exception; |
| 4 | |
| 5 | use AmeliaVendor\Psr\Http\Message\RequestInterface; |
| 6 | |
| 7 | /** |
| 8 | * Exception for when a request failed, providing access to the failed request. |
| 9 | * |
| 10 | * This could be due to an invalid request, or one of the extending exceptions |
| 11 | * for network errors or HTTP error responses. |
| 12 | * |
| 13 | * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> |
| 14 | */ |
| 15 | class RequestException extends TransferException |
| 16 | { |
| 17 | /** |
| 18 | * @var RequestInterface |
| 19 | */ |
| 20 | private $request; |
| 21 | |
| 22 | /** |
| 23 | * @param string $message |
| 24 | * @param RequestInterface $request |
| 25 | * @param \Exception|null $previous |
| 26 | */ |
| 27 | public function __construct($message, RequestInterface $request, \Exception $previous = null) |
| 28 | { |
| 29 | $this->request = $request; |
| 30 | |
| 31 | parent::__construct($message, 0, $previous); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Returns the request. |
| 36 | * |
| 37 | * @return RequestInterface |
| 38 | */ |
| 39 | public function getRequest() |
| 40 | { |
| 41 | return $this->request; |
| 42 | } |
| 43 | } |
| 44 |