vendor/ruflin/elastica/src/Exception/Bulk/Response/ActionException.php line 9

Open in your IDE?
  1. <?php
  2. namespace Elastica\Exception\Bulk\Response;
  3. use Elastica\Bulk\Action;
  4. use Elastica\Bulk\Response as BulkResponse;
  5. use Elastica\Exception\BulkException;
  6. class ActionException extends BulkException
  7. {
  8.     /**
  9.      * @var BulkResponse
  10.      */
  11.     protected $_response;
  12.     public function __construct(BulkResponse $response)
  13.     {
  14.         $this->_response $response;
  15.         parent::__construct($this->getErrorMessage($response));
  16.     }
  17.     public function getAction(): Action
  18.     {
  19.         return $this->getResponse()->getAction();
  20.     }
  21.     public function getResponse(): BulkResponse
  22.     {
  23.         return $this->_response;
  24.     }
  25.     public function getErrorMessage(BulkResponse $response): string
  26.     {
  27.         $error $response->getError();
  28.         $opType $response->getOpType();
  29.         $data $response->getData();
  30.         $path '';
  31.         if (isset($data['_index'])) {
  32.             $path .= '/'.$data['_index'];
  33.         }
  34.         if (isset($data['_type'])) {
  35.             $path .= '/'.$data['_type'];
  36.         }
  37.         if (isset($data['_id'])) {
  38.             $path .= '/'.$data['_id'];
  39.         }
  40.         return "{$opType}{$path} caused {$error}";
  41.     }
  42. }