Skip to content

Commit be227f2

Browse files
committed
ruflin#687 Improve exception handling in Type::getDocument()
1 parent 76074c2 commit be227f2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Elastica/Type.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,12 @@ public function getDocument($id, $options = array())
224224
{
225225
$path = urlencode($id);
226226

227-
$response = $this->request($path, Request::GET, array(), $options);
228-
$result = $response->getData();
227+
try {
228+
$response = $this->request($path, Request::GET, array(), $options);
229+
$result = $response->getData();
230+
} catch (ResponseException $e) {
231+
throw new NotFoundException('unable to retrieve doc id ' . $id. ': '.$e->getMessage(), $e->getCode(), $e);
232+
}
229233

230234
$info = $response->getTransferInfo();
231235
if ($info['http_code'] !== 200) {

0 commit comments

Comments
 (0)