From 3c83676016bce1727f0046f4aad7865be8a71fd4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 7 May 2012 20:36:13 +0200 Subject: use httprequest wrapper to automatically check for errors --- .../Database/Adapter/Elasticsearch/HTTPRequest.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php (limited to 'src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php') diff --git a/src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php b/src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php new file mode 100644 index 0000000..2d74a4e --- /dev/null +++ b/src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php @@ -0,0 +1,25 @@ +getStatus() / 100); + if ($mainCode != 2) { + $js = json_decode($res->getBody()); + if (isset($js->error)) { + $error = $js->error; + } else { + $error = $res->getBody(); + } + throw new Exception( + 'Error in elasticsearch communication: ' . $error + ); + } + return $res; + } +} + +?> -- cgit v1.2.3