vendor/ruflin/elastica/src/Exception/ResponseException.php line 13

Open in your IDE?
  1. <?php
  2. namespace Elastica\Exception;
  3. use Elastica\Request;
  4. use Elastica\Response;
  5. /**
  6.  * Response exception.
  7.  *
  8.  * @author Nicolas Ruflin <spam@ruflin.com>
  9.  */
  10. class ResponseException extends \RuntimeException implements ExceptionInterface
  11. {
  12.     /**
  13.      * @var Request Request object
  14.      */
  15.     protected $_request;
  16.     /**
  17.      * @var Response Response object
  18.      */
  19.     protected $_response;
  20.     /**
  21.      * Construct Exception.
  22.      */
  23.     public function __construct(Request $requestResponse $response)
  24.     {
  25.         $this->_request $request;
  26.         $this->_response $response;
  27.         parent::__construct($response->getErrorMessage());
  28.     }
  29.     /**
  30.      * Returns request object.
  31.      *
  32.      * @return Request Request object
  33.      */
  34.     public function getRequest(): Request
  35.     {
  36.         return $this->_request;
  37.     }
  38.     /**
  39.      * Returns response object.
  40.      *
  41.      * @return Response Response object
  42.      */
  43.     public function getResponse(): Response
  44.     {
  45.         return $this->_response;
  46.     }
  47.     /**
  48.      * Returns elasticsearch exception.
  49.      *
  50.      * @deprecated since version 7.1.0, use the "getResponse()::getFullError()" method instead.
  51.      */
  52.     public function getElasticsearchException(): ElasticsearchException
  53.     {
  54.         \trigger_deprecation('ruflin/elastica''7.1.0''The "%s()" method is deprecated, use "getResponse()::getFullError()" instead. It will be removed in 8.0.'__METHOD__);
  55.         $response $this->getResponse();
  56.         return new ElasticsearchException($response->getStatus(), $response->getErrorMessage());
  57.     }
  58. }