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 d03ef3ecb317b3f280684b54d939d8b34be95e86..3c3ea8351f2397f373f6bd5951a9272b19f1b2d7 100644 (file)
@@ -53,9 +53,13 @@ class Search_Elasticsearch
                 )
             )
         );
                 )
             )
         );
-        //FIXME: error handling
         $httpRes = $r->send();
         $jRes = json_decode($httpRes->getBody());
         $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;
 
         $sres = new Search_Result();
         $sres->results = $jRes->hits->total;