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