Skip to content

Commit

Permalink
Merge pull request #118 from bakaphp/0.6-update-elastci-error-reporting
Browse files Browse the repository at this point in the history
[0.6] Improve Elastic Error Reporting
  • Loading branch information
kaioken authored Apr 27, 2021
2 parents a1a1846 + 69b0045 commit e87b398
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Elasticsearch/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Baka\Elasticsearch\Query\FromClause;
use function Baka\envValue;
use Baka\Exception\Exception;
use Baka\Exception\HttpException;
use Phalcon\Di;
use Phalcon\Mvc\Model\Query\Builder;
use SplFixedArray;
Expand Down Expand Up @@ -65,8 +66,14 @@ public function find() : array
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$results = curl_exec($ch);
if (!$results) {
$message = 'Elastic error: ' . curl_error($ch);
throw new HttpException($message, 500);
}

// Send request.
$results = json_decode(curl_exec($ch), true);
$results = json_decode($results, true);

if (isset($results['error'])) {
throw Exception::create(
Expand Down

0 comments on commit e87b398

Please sign in to comment.