|
21 | 21 | use MongoDB\Driver\Command; |
22 | 22 | use MongoDB\Driver\CursorInterface; |
23 | 23 | use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException; |
| 24 | +use MongoDB\Driver\Exception\ServerException; |
24 | 25 | use MongoDB\Driver\ReadConcern; |
25 | 26 | use MongoDB\Driver\ReadPreference; |
26 | 27 | use MongoDB\Driver\Server; |
27 | 28 | use MongoDB\Driver\Session; |
28 | 29 | use MongoDB\Driver\WriteConcern; |
29 | 30 | use MongoDB\Exception\InvalidArgumentException; |
| 31 | +use MongoDB\Exception\SearchNotSupportedException; |
30 | 32 | use MongoDB\Exception\UnexpectedValueException; |
31 | 33 | use MongoDB\Exception\UnsupportedException; |
32 | 34 | use MongoDB\Model\CodecCursor; |
@@ -233,7 +235,15 @@ public function execute(Server $server): CursorInterface |
233 | 235 | $this->createCommandOptions(), |
234 | 236 | ); |
235 | 237 |
|
236 | | - $cursor = $this->executeCommand($server, $command); |
| 238 | + try { |
| 239 | + $cursor = $this->executeCommand($server, $command); |
| 240 | + } catch (ServerException $exception) { |
| 241 | + if (SearchNotSupportedException::isSearchNotSupportedError($exception)) { |
| 242 | + throw new SearchNotSupportedException('Search is not supported by the connected server', $exception->getCode(), $exception); |
| 243 | + } |
| 244 | + |
| 245 | + throw $exception; |
| 246 | + } |
237 | 247 |
|
238 | 248 | if (isset($this->options['codec'])) { |
239 | 249 | return CodecCursor::fromCursor($cursor, $this->options['codec']); |
|
0 commit comments