aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/http/lib/ClientHttpException.php
blob: 116ca1f79278ac12311a26c73e5d7708c48c97da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

declare(strict_types=1);

namespace Sabre\HTTP;

/**
 * This exception represents a HTTP error coming from the Client.
 *
 * By default the Client will not emit these, this has to be explicitly enabled
 * with the setThrowExceptions method.
 *
 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
 * @author Evert Pot (http://evertpot.com/)
 * @license http://sabre.io/license/ Modified BSD License
 */
class ClientHttpException extends \Exception implements HttpException
{
    /**
     * Response object.
     *
     * @var ResponseInterface
     */
    protected $response;

    /**
     * Constructor.
     */
    public function __construct(ResponseInterface $response)
    {
        $this->response = $response;
        parent::__construct($response->getStatusText(), $response->getStatus());
    }

    /**
     * The http status code for the error.
     */
    public function getHttpStatus(): int
    {
        return $this->response->getStatus();
    }

    /**
     * Returns the full response object.
     */
    public function getResponse(): ResponseInterface
    {
        return $this->response;
    }
}