Skip to content

Commit

Permalink
ruflin#687 Improve exception handling in Type::getDocument()
Browse files Browse the repository at this point in the history
  • Loading branch information
rmruano committed Oct 5, 2014
1 parent 76074c2 commit be227f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Elastica/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,12 @@ public function getDocument($id, $options = array())
{
$path = urlencode($id);

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

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

0 comments on commit be227f2

Please sign in to comment.