diff options
Diffstat (limited to 'src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php')
| -rw-r--r-- | src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php b/src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php new file mode 100644 index 0000000..2d74a4e --- /dev/null +++ b/src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php @@ -0,0 +1,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; + } +} + +?> |
