class HttpException
Same name in this branch
- 11.1.x vendor/symfony/http-kernel/Exception/HttpException.php \Symfony\Component\HttpKernel\Exception\HttpException
Thrown when a response was received but the request itself failed.
In addition to the request, this exception always provides access to the response object.
@author Márk Sági-Kazár <mark.sagikazar@gmail.com>
Hierarchy
- class \Http\Client\Exception\TransferException extends \Http\Client\Exception\RuntimeException implements \Http\Client\Exception
- class \Http\Client\Exception\RequestException extends \Http\Client\Exception\TransferException implements \Psr\Http\Client\RequestExceptionInterface uses \Http\Client\Exception\RequestAwareTrait
- class \Http\Client\Exception\HttpException extends \Http\Client\Exception\RequestException
- class \Http\Client\Exception\RequestException extends \Http\Client\Exception\TransferException implements \Psr\Http\Client\RequestExceptionInterface uses \Http\Client\Exception\RequestAwareTrait
Expanded class hierarchy of HttpException
File
-
vendor/
php-http/ httplug/ src/ Exception/ HttpException.php, line 15
Namespace
Http\Client\ExceptionView source
class HttpException extends RequestException {
/**
* @var ResponseInterface
*/
protected $response;
/**
* @param string $message
*/
public function __construct($message, RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null) {
parent::__construct($message, $request, $previous);
$this->response = $response;
$this->code = $response->getStatusCode();
}
/**
* Returns the response.
*
* @return ResponseInterface
*/
public function getResponse() {
return $this->response;
}
/**
* Factory method to create a new exception with a normalized error message.
*/
public static function create(RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null) {
$message = sprintf('[url] %s [http method] %s [status code] %s [reason phrase] %s', $request->getRequestTarget(), $request->getMethod(), $response->getStatusCode(), $response->getReasonPhrase());
return new static($message, $request, $response, $previous);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
HttpException::$response | protected | property | ||
HttpException::create | public static | function | Factory method to create a new exception with a normalized error message. | |
HttpException::getResponse | public | function | Returns the response. | |
HttpException::__construct | public | function | Overrides RequestException::__construct | |
RequestAwareTrait::$request | private | property | ||
RequestAwareTrait::getRequest | public | function | ||
RequestAwareTrait::setRequest | private | function |