summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php51
1 files changed, 51 insertions, 0 deletions
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..645c0eff
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Elastica\Exception\Connection;
+
+use Elastica\Exception\ConnectionException;
+use Elastica\Request;
+use Elastica\Response;
+use GuzzleHttp\Exception\TransferException;
+
+/**
+ * Transport exception
+ *
+ * @package Elastica
+ * @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;
+ }
+}