xref: /plugin/davcal/vendor/sabre/http/lib/ClientHttpException.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\HTTP;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehler/**
6*a1a3b679SAndreas Boehler * This exception represents a HTTP error coming from the Client.
7*a1a3b679SAndreas Boehler *
8*a1a3b679SAndreas Boehler * By default the Client will not emit these, this has to be explicitly enabled
9*a1a3b679SAndreas Boehler * with the setThrowExceptions method.
10*a1a3b679SAndreas Boehler *
11*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/).
12*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/)
13*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License
14*a1a3b679SAndreas Boehler */
15*a1a3b679SAndreas Boehlerclass ClientHttpException extends \Exception implements HttpException {
16*a1a3b679SAndreas Boehler
17*a1a3b679SAndreas Boehler    /**
18*a1a3b679SAndreas Boehler     * Response object
19*a1a3b679SAndreas Boehler     *
20*a1a3b679SAndreas Boehler     * @var ResponseInterface
21*a1a3b679SAndreas Boehler     */
22*a1a3b679SAndreas Boehler    protected $response;
23*a1a3b679SAndreas Boehler
24*a1a3b679SAndreas Boehler    /**
25*a1a3b679SAndreas Boehler     * Constructor
26*a1a3b679SAndreas Boehler     *
27*a1a3b679SAndreas Boehler     * @param ResponseInterface $response
28*a1a3b679SAndreas Boehler     */
29*a1a3b679SAndreas Boehler    function __construct(ResponseInterface $response) {
30*a1a3b679SAndreas Boehler
31*a1a3b679SAndreas Boehler        $this->response = $response;
32*a1a3b679SAndreas Boehler        parent::__construct($response->getStatusText(), $response->getStatus());
33*a1a3b679SAndreas Boehler
34*a1a3b679SAndreas Boehler    }
35*a1a3b679SAndreas Boehler
36*a1a3b679SAndreas Boehler    /**
37*a1a3b679SAndreas Boehler     * The http status code for the error.
38*a1a3b679SAndreas Boehler     *
39*a1a3b679SAndreas Boehler     * @return int
40*a1a3b679SAndreas Boehler     */
41*a1a3b679SAndreas Boehler    function getHttpStatus() {
42*a1a3b679SAndreas Boehler
43*a1a3b679SAndreas Boehler        return $this->response->getStatus();
44*a1a3b679SAndreas Boehler
45*a1a3b679SAndreas Boehler    }
46*a1a3b679SAndreas Boehler
47*a1a3b679SAndreas Boehler    /**
48*a1a3b679SAndreas Boehler     * Returns the full response object.
49*a1a3b679SAndreas Boehler     *
50*a1a3b679SAndreas Boehler     * @return ResponseInterface
51*a1a3b679SAndreas Boehler     */
52*a1a3b679SAndreas Boehler    function getResponse() {
53*a1a3b679SAndreas Boehler
54*a1a3b679SAndreas Boehler        return $this->response;
55*a1a3b679SAndreas Boehler
56*a1a3b679SAndreas Boehler    }
57*a1a3b679SAndreas Boehler
58*a1a3b679SAndreas Boehler}
59