blob: 2d74a4e03470213a6d837172cda06fa08193e0e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
namespace phorkie;
class Database_Adapter_Elasticsearch_HTTPRequest extends \HTTP_Request2
{
public function send()
{
$res = parent::send();
$mainCode = intval($res->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;
}
}
?>
|