From 226508cd8d3e8c147ad314a0de483e08be71c254 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 3 Feb 2016 06:21:30 +0100 Subject: first frontend --- src/phinde/Elasticsearch/Request.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/phinde/Elasticsearch/Request.php (limited to 'src/phinde/Elasticsearch/Request.php') diff --git a/src/phinde/Elasticsearch/Request.php b/src/phinde/Elasticsearch/Request.php new file mode 100644 index 0000000..7bb6add --- /dev/null +++ b/src/phinde/Elasticsearch/Request.php @@ -0,0 +1,35 @@ +getStatus() / 100); + if ($mainCode === 2) { + return $res; + } + + if ($this->allow404 && $res->getStatus() == 404) { + return $res; + } + $js = json_decode($res->getBody()); + if (isset($js->error)) { + $error = json_encode($js->error); + } else { + $error = $res->getBody(); + } + + throw new \Exception( + 'Error in elasticsearch communication at ' + . $this->getMethod() . ' ' . (string) $this->getUrl() + . ' (status code ' . $res->getStatus() . '): ' + . $error + ); + } +} + +?> -- cgit v1.2.3