From: Christian Weiske Date: Tue, 1 May 2012 19:29:48 +0000 (+0200) Subject: throw exception when search throws exception X-Git-Tag: v0.2.0~35 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/9e1b6dbecf1ebc160b8ceca14ecade816638790b throw exception when search throws exception --- diff --git a/src/phorkie/Search/Elasticsearch.php b/src/phorkie/Search/Elasticsearch.php index d03ef3e..3c3ea83 100644 --- a/src/phorkie/Search/Elasticsearch.php +++ b/src/phorkie/Search/Elasticsearch.php @@ -53,9 +53,13 @@ class Search_Elasticsearch ) ) ); - //FIXME: error handling $httpRes = $r->send(); $jRes = json_decode($httpRes->getBody()); + if (isset($jRes->error)) { + throw new Exception( + 'Search exception: ' . $jRes->error, $jRes->status + ); + } $sres = new Search_Result(); $sres->results = $jRes->hits->total;