Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exception handling in Type::getDocument() #693

Merged
merged 3 commits into from
Oct 8, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CHANGES

2014-10-05
- Remove exception catch in Type::getDocument() #687

2014-10-04
- Release v1.3.4.0
- Update to elasticsearch 1.3.4 #691
Expand Down
8 changes: 2 additions & 6 deletions lib/Elastica/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,8 @@ public function getDocument($id, $options = array())
{
$path = urlencode($id);

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

$info = $response->getTransferInfo();
if ($info['http_code'] !== 200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a BC break, you should be passing the previous exception to the new one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, I've upgraded it to the other proposal I did which doesn't break BC, but IMHO It doesn't seem appropiate to throw a NotFoundException for ResponseExceptions.

Expand Down