throw exception when search throws exception
authorChristian Weiske <cweiske@cweiske.de>
Tue, 1 May 2012 19:29:48 +0000 (21:29 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 1 May 2012 19:29:48 +0000 (21:29 +0200)
src/phorkie/Search/Elasticsearch.php

index d03ef3e..3c3ea83 100644 (file)
@@ -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;