summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Exception
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Exception')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php65
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php98
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php8
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php6
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php50
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php86
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php49
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php58
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php91
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php9
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php28
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php70
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php11
20 files changed, 710 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php
new file mode 100644
index 00000000..5db0e49f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php
@@ -0,0 +1,65 @@
+<?php
+namespace Elastica\Exception\Bulk\Response;
+
+use Elastica\Bulk\Response;
+use Elastica\Exception\BulkException;
+
+class ActionException extends BulkException
+{
+ /**
+ * @var \Elastica\Response
+ */
+ protected $_response;
+
+ /**
+ * @param \Elastica\Bulk\Response $response
+ */
+ public function __construct(Response $response)
+ {
+ $this->_response = $response;
+
+ parent::__construct($this->getErrorMessage($response));
+ }
+
+ /**
+ * @return \Elastica\Bulk\Action
+ */
+ public function getAction()
+ {
+ return $this->getResponse()->getAction();
+ }
+
+ /**
+ * @return \Elastica\Bulk\Response
+ */
+ public function getResponse()
+ {
+ return $this->_response;
+ }
+
+ /**
+ * @param \Elastica\Bulk\Response $response
+ *
+ * @return string
+ */
+ public function getErrorMessage(Response $response)
+ {
+ $error = $response->getError();
+ $opType = $response->getOpType();
+ $data = $response->getData();
+
+ $path = '';
+ if (isset($data['_index'])) {
+ $path .= '/'.$data['_index'];
+ }
+ if (isset($data['_type'])) {
+ $path .= '/'.$data['_type'];
+ }
+ if (isset($data['_id'])) {
+ $path .= '/'.$data['_id'];
+ }
+ $message = "$opType: $path caused $error";
+
+ return $message;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php
new file mode 100644
index 00000000..54b5702b
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php
@@ -0,0 +1,98 @@
+<?php
+namespace Elastica\Exception\Bulk;
+
+use Elastica\Bulk\ResponseSet;
+use Elastica\Exception\Bulk\Response\ActionException;
+use Elastica\Exception\BulkException;
+
+/**
+ * Bulk Response exception.
+ */
+class ResponseException extends BulkException
+{
+ /**
+ * @var \Elastica\Bulk\ResponseSet ResponseSet object
+ */
+ protected $_responseSet;
+
+ /**
+ * @var \Elastica\Exception\Bulk\Response\ActionException[]
+ */
+ protected $_actionExceptions = array();
+
+ /**
+ * Construct Exception.
+ *
+ * @param \Elastica\Bulk\ResponseSet $responseSet
+ */
+ public function __construct(ResponseSet $responseSet)
+ {
+ $this->_init($responseSet);
+
+ $message = 'Error in one or more bulk request actions:'.PHP_EOL.PHP_EOL;
+ $message .= $this->getActionExceptionsAsString();
+
+ parent::__construct($message);
+ }
+
+ /**
+ * @param \Elastica\Bulk\ResponseSet $responseSet
+ */
+ protected function _init(ResponseSet $responseSet)
+ {
+ $this->_responseSet = $responseSet;
+
+ foreach ($responseSet->getBulkResponses() as $bulkResponse) {
+ if ($bulkResponse->hasError()) {
+ $this->_actionExceptions[] = new ActionException($bulkResponse);
+ }
+ }
+ }
+
+ /**
+ * Returns bulk response set object.
+ *
+ * @return \Elastica\Bulk\ResponseSet
+ */
+ public function getResponseSet()
+ {
+ return $this->_responseSet;
+ }
+
+ /**
+ * Returns array of failed actions.
+ *
+ * @return array Array of failed actions
+ */
+ public function getFailures()
+ {
+ $errors = array();
+
+ foreach ($this->getActionExceptions() as $actionException) {
+ $errors[] = $actionException->getMessage();
+ }
+
+ return $errors;
+ }
+
+ /**
+ * @return \Elastica\Exception\Bulk\Response\ActionException[]
+ */
+ public function getActionExceptions()
+ {
+ return $this->_actionExceptions;
+ }
+
+ /**
+ * @return string
+ */
+ public function getActionExceptionsAsString()
+ {
+ $message = '';
+ foreach ($this->getActionExceptions() as $actionException) {
+ $message .= $actionException->getMessage().PHP_EOL;
+ }
+
+ return $message;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php
new file mode 100644
index 00000000..e332b92f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Exception\Bulk;
+
+use Elastica\Exception\BulkException;
+
+class UdpException extends BulkException
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php
new file mode 100644
index 00000000..121cf557
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Exception;
+
+class BulkException extends \RuntimeException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php
new file mode 100644
index 00000000..66af363d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * Client exception.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class ClientException extends \RuntimeException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
new file mode 100644
index 00000000..614ad139
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
@@ -0,0 +1,50 @@
+<?php
+namespace Elastica\Exception\Connection;
+
+use Elastica\Exception\ConnectionException;
+use Elastica\Request;
+use Elastica\Response;
+use GuzzleHttp\Exception\TransferException;
+
+/**
+ * Transport exception.
+ *
+ * @author Milan Magudia <milan@magudia.com>
+ */
+class GuzzleException extends ConnectionException
+{
+ /**
+ * @var TransferException
+ */
+ protected $_guzzleException;
+
+ /**
+ * @param \GuzzleHttp\Exception\TransferException $guzzleException
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
+ */
+ public function __construct(TransferException $guzzleException, Request $request = null, Response $response = null)
+ {
+ $this->_guzzleException = $guzzleException;
+ $message = $this->getErrorMessage($this->getGuzzleException());
+ parent::__construct($message, $request, $response);
+ }
+
+ /**
+ * @param \GuzzleHttp\Exception\TransferException $guzzleException
+ *
+ * @return string
+ */
+ public function getErrorMessage(TransferException $guzzleException)
+ {
+ return $guzzleException->getMessage();
+ }
+
+ /**
+ * @return TransferException
+ */
+ public function getGuzzleException()
+ {
+ return $this->_guzzleException;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php
new file mode 100644
index 00000000..28e78e77
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php
@@ -0,0 +1,86 @@
+<?php
+namespace Elastica\Exception\Connection;
+
+use Elastica\Exception\ConnectionException;
+use Elastica\Request;
+use Elastica\Response;
+
+/**
+ * Connection exception.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class HttpException extends ConnectionException
+{
+ /**
+ * Error code / message.
+ *
+ * @var string Error code / message
+ */
+ protected $_error = 0;
+
+ /**
+ * Construct Exception.
+ *
+ * @param string $error Error
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
+ */
+ public function __construct($error, Request $request = null, Response $response = null)
+ {
+ $this->_error = $error;
+
+ $message = $this->getErrorMessage($this->getError());
+ parent::__construct($message, $request, $response);
+ }
+
+ /**
+ * Returns the error message corresponding to the error code
+ * cUrl error code reference can be found here {@link http://curl.haxx.se/libcurl/c/libcurl-errors.html}.
+ *
+ * @param string $error Error code
+ *
+ * @return string Error message
+ */
+ public function getErrorMessage($error)
+ {
+ switch ($error) {
+ case CURLE_UNSUPPORTED_PROTOCOL:
+ $error = 'Unsupported protocol';
+ break;
+ case CURLE_FAILED_INIT:
+ $error = 'Internal cUrl error?';
+ break;
+ case CURLE_URL_MALFORMAT:
+ $error = 'Malformed URL';
+ break;
+ case CURLE_COULDNT_RESOLVE_PROXY:
+ $error = "Couldn't resolve proxy";
+ break;
+ case CURLE_COULDNT_RESOLVE_HOST:
+ $error = "Couldn't resolve host";
+ break;
+ case CURLE_COULDNT_CONNECT:
+ $error = "Couldn't connect to host, Elasticsearch down?";
+ break;
+ case 28:
+ $error = 'Operation timed out';
+ break;
+ default:
+ $error = 'Unknown error:'.$error;
+ break;
+ }
+
+ return $error;
+ }
+
+ /**
+ * Return Error code / message.
+ *
+ * @return string Error code / message
+ */
+ public function getError()
+ {
+ return $this->_error;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php
new file mode 100644
index 00000000..24181379
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php
@@ -0,0 +1,13 @@
+<?php
+namespace Elastica\Exception\Connection;
+
+use Elastica\Exception\ConnectionException;
+
+/**
+ * Transport exception.
+ *
+ * @author Igor Denisenko <im.denisenko@yahoo.com>
+ */
+class MemcacheException extends ConnectionException
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php
new file mode 100644
index 00000000..499cbd7d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php
@@ -0,0 +1,49 @@
+<?php
+namespace Elastica\Exception\Connection;
+
+use Elastica\Exception\ConnectionException;
+use Elastica\Request;
+use Elastica\Response;
+use Thrift\Exception\TException;
+
+/**
+ * Transport exception.
+ *
+ * @author Mikhail Shamin <munk13@gmail.com>
+ */
+class ThriftException extends ConnectionException
+{
+ /**
+ * @var TException
+ */
+ protected $_thriftException;
+
+ /**
+ * @param \Thrift\Exception\TException $thriftException
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
+ */
+ public function __construct(TException $thriftException, Request $request = null, Response $response = null)
+ {
+ $this->_thriftException = $thriftException;
+ $message = $this->getErrorMessage($this->getThriftException());
+ parent::__construct($message, $request, $response);
+ }
+
+ /**
+ * @param \Thrift\Exception\TException $thriftException
+ *
+ * @return string
+ */
+ public function getErrorMessage(TException $thriftException)
+ {
+ return $thriftException->getMessage();
+ }
+ /**
+ * @return TException
+ */
+ public function getThriftException()
+ {
+ return $this->_thriftException;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php
new file mode 100644
index 00000000..b2376d2f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php
@@ -0,0 +1,58 @@
+<?php
+namespace Elastica\Exception;
+
+use Elastica\Request;
+use Elastica\Response;
+
+/**
+ * Connection exception.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class ConnectionException extends \RuntimeException implements ExceptionInterface
+{
+ /**
+ * @var \Elastica\Request Request object
+ */
+ protected $_request;
+
+ /**
+ * @var \Elastica\Response Response object
+ */
+ protected $_response;
+
+ /**
+ * Construct Exception.
+ *
+ * @param string $message Message
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
+ */
+ public function __construct($message, Request $request = null, Response $response = null)
+ {
+ $this->_request = $request;
+ $this->_response = $response;
+
+ parent::__construct($message);
+ }
+
+ /**
+ * Returns request object.
+ *
+ * @return \Elastica\Request Request object
+ */
+ public function getRequest()
+ {
+ return $this->_request;
+ }
+
+ /**
+ * Returns response object.
+ *
+ * @return \Elastica\Response Response object
+ */
+ public function getResponse()
+ {
+ return $this->_response;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php
new file mode 100644
index 00000000..59cca0c6
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php
@@ -0,0 +1,91 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * Elasticsearch exception.
+ *
+ * @author Ian Babrou <ibobrik@gmail.com>
+ */
+class ElasticsearchException extends \Exception implements ExceptionInterface
+{
+ const REMOTE_TRANSPORT_EXCEPTION = 'RemoteTransportException';
+
+ /**
+ * @var string|null Elasticsearch exception name
+ */
+ private $_exception;
+
+ /**
+ * @var bool Whether exception was local to server node or remote
+ */
+ private $_isRemote = false;
+
+ /**
+ * Constructs elasticsearch exception.
+ *
+ * @param int $code Error code
+ * @param string $error Error message from elasticsearch
+ */
+ public function __construct($code, $error)
+ {
+ $this->_parseError($error);
+ parent::__construct($error, $code);
+ }
+
+ /**
+ * Parse error message from elasticsearch.
+ *
+ * @param string $error Error message
+ */
+ protected function _parseError($error)
+ {
+ $errors = explode(']; nested: ', $error);
+
+ if (count($errors) == 1) {
+ $this->_exception = $this->_extractException($errors[0]);
+ } else {
+ if ($this->_extractException($errors[0]) == self::REMOTE_TRANSPORT_EXCEPTION) {
+ $this->_isRemote = true;
+ $this->_exception = $this->_extractException($errors[1]);
+ } else {
+ $this->_exception = $this->_extractException($errors[0]);
+ }
+ }
+ }
+
+ /**
+ * Extract exception name from error response.
+ *
+ * @param string $error
+ *
+ * @return null|string
+ */
+ protected function _extractException($error)
+ {
+ if (preg_match('/^(\w+)\[.*\]/', $error, $matches)) {
+ return $matches[1];
+ } else {
+ return;
+ }
+ }
+
+ /**
+ * Returns elasticsearch exception name.
+ *
+ * @return string|null
+ */
+ public function getExceptionName()
+ {
+ return $this->_exception;
+ }
+
+ /**
+ * Returns whether exception was local to server node or remote.
+ *
+ * @return bool
+ */
+ public function isRemoteTransportException()
+ {
+ return $this->_isRemote;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php
new file mode 100644
index 00000000..02f43092
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * General Elastica exception interface.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+interface ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php
new file mode 100644
index 00000000..996a9389
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * Invalid exception.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class InvalidException extends \InvalidArgumentException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php
new file mode 100644
index 00000000..010adf45
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php
@@ -0,0 +1,9 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * JSON Parse exception.
+ */
+class JSONParseException extends \RuntimeException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php
new file mode 100644
index 00000000..a2897fd7
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * Not found exception.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class NotFoundException extends \RuntimeException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php
new file mode 100644
index 00000000..591417b6
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php
@@ -0,0 +1,13 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * Not implemented exception.
+ *
+ * Is thrown if a function or feature is not implemented yet
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class NotImplementedException extends \BadMethodCallException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php
new file mode 100644
index 00000000..bb3fa44a
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php
@@ -0,0 +1,28 @@
+<?php
+namespace Elastica\Exception;
+
+use Elastica\JSON;
+use Elastica\Request;
+use Elastica\Response;
+
+/**
+ * Partial shard failure exception.
+ *
+ * @author Ian Babrou <ibobrik@gmail.com>
+ */
+class PartialShardFailureException extends ResponseException
+{
+ /**
+ * Construct Exception.
+ *
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
+ */
+ public function __construct(Request $request, Response $response)
+ {
+ parent::__construct($request, $response);
+
+ $shardsStatistics = $response->getShardsStatistics();
+ $this->message = JSON::stringify($shardsStatistics['failed']);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php
new file mode 100644
index 00000000..ae03c831
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * QueryBuilder exception.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class QueryBuilderException extends \RuntimeException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php
new file mode 100644
index 00000000..57502307
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php
@@ -0,0 +1,70 @@
+<?php
+namespace Elastica\Exception;
+
+use Elastica\Request;
+use Elastica\Response;
+
+/**
+ * Response exception.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+class ResponseException extends \RuntimeException implements ExceptionInterface
+{
+ /**
+ * @var \Elastica\Request Request object
+ */
+ protected $_request = null;
+
+ /**
+ * @var \Elastica\Response Response object
+ */
+ protected $_response = null;
+
+ /**
+ * Construct Exception.
+ *
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
+ */
+ public function __construct(Request $request, Response $response)
+ {
+ $this->_request = $request;
+ $this->_response = $response;
+ parent::__construct($response->getError());
+ }
+
+ /**
+ * Returns request object.
+ *
+ * @return \Elastica\Request Request object
+ */
+ public function getRequest()
+ {
+ return $this->_request;
+ }
+
+ /**
+ * Returns response object.
+ *
+ * @return \Elastica\Response Response object
+ */
+ public function getResponse()
+ {
+ return $this->_response;
+ }
+
+ /**
+ * Returns elasticsearch exception.
+ *
+ * @return ElasticsearchException
+ */
+ public function getElasticsearchException()
+ {
+ $response = $this->getResponse();
+ $transfer = $response->getTransferInfo();
+ $code = array_key_exists('http_code', $transfer) ? $transfer['http_code'] : 0;
+
+ return new ElasticsearchException($code, $response->getError());
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php
new file mode 100644
index 00000000..af18faff
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * Client exception.
+ *
+ * @author Mikhail Shamin <munk13@gmail.com>
+ */
+class RuntimeException extends \RuntimeException implements ExceptionInterface
+{
+}