Skip to content

PHPLIB-636: ListIndexes should use CommandException for catching missing namespace and database errors #837

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

Merged
merged 3 commits into from
Jul 2, 2021
Merged
Changes from all commits
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: 2 additions & 1 deletion src/Operation/ListIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use EmptyIterator;
use MongoDB\Driver\Command;
use MongoDB\Driver\Exception\CommandException;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
Copy link
Member

Choose a reason for hiding this comment

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

Related to my comment below, I think we may actually need to leave this line in place to satisfy the reference in @throws (phpcs might complain otherwise, even though it's just in a comment). So CommandException should probably be added as a new line.

use MongoDB\Driver\Server;
use MongoDB\Driver\Session;
Expand Down Expand Up @@ -135,7 +136,7 @@ private function executeCommand(Server $server)

try {
$cursor = $server->executeReadCommand($this->databaseName, new Command($cmd), $this->createOptions());
} catch (DriverRuntimeException $e) {
} catch (CommandException $e) {
/* The server may return an error if the collection does not exist.
* Check for possible error codes (see: SERVER-20463) and return an
* empty iterator instead of throwing.
Expand Down