HttpException.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage App
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Zend_Gdata_App_Exception
  23. */
  24. require_once 'Zend/Gdata/App/Exception.php';
  25. /**
  26. * Zend_Http_Client_Exception
  27. */
  28. require_once 'Zend/Http/Client/Exception.php';
  29. /**
  30. * Gdata exceptions
  31. *
  32. * Class to represent exceptions that occur during Gdata operations.
  33. *
  34. * @category Zend
  35. * @package Zend_Gdata
  36. * @subpackage App
  37. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Gdata_App_HttpException extends Zend_Gdata_App_Exception
  41. {
  42. protected $_httpClientException = null;
  43. protected $_response = null;
  44. /**
  45. * Create a new Zend_Gdata_App_HttpException
  46. *
  47. * @param string $message Optionally set a message
  48. * @param Zend_Http_Client_Exception Optionally pass in a Zend_Http_Client_Exception
  49. * @param Zend_Http_Response Optionally pass in a Zend_Http_Response
  50. */
  51. public function __construct($message = null, $e = null, $response = null)
  52. {
  53. $this->_httpClientException = $e;
  54. $this->_response = $response;
  55. parent::__construct($message);
  56. }
  57. /**
  58. * Get the Zend_Http_Client_Exception.
  59. *
  60. * @return Zend_Http_Client_Exception
  61. */
  62. public function getHttpClientException()
  63. {
  64. return $this->_httpClientException;
  65. }
  66. /**
  67. * Set the Zend_Http_Client_Exception.
  68. *
  69. * @param Zend_Http_Client_Exception $value
  70. */
  71. public function setHttpClientException($value)
  72. {
  73. $this->_httpClientException = $value;
  74. return $this;
  75. }
  76. /**
  77. * Set the Zend_Http_Response.
  78. *
  79. * @param Zend_Http_Response $response
  80. */
  81. public function setResponse($response)
  82. {
  83. $this->_response = $response;
  84. return $this;
  85. }
  86. /**
  87. * Get the Zend_Http_Response.
  88. *
  89. * @return Zend_Http_Response
  90. */
  91. public function getResponse()
  92. {
  93. return $this->_response;
  94. }
  95. /**
  96. * Get the body of the Zend_Http_Response
  97. *
  98. * @return string
  99. */
  100. public function getRawResponseBody()
  101. {
  102. if ($this->getResponse()) {
  103. $response = $this->getResponse();
  104. return $response->getRawBody();
  105. }
  106. return null;
  107. }
  108. }