File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ public static function collationNotSupported()
3939 return new static ('Collations are not supported by the server executing this operation ' );
4040 }
4141
42+ /**
43+ * Thrown when the commitQuorum option for createIndexes is not supported
44+ * by a server.
45+ *
46+ * @return self
47+ */
48+ public static function commitQuorumNotSupported ()
49+ {
50+ return new static ('The "commitQuorum" option is not supported by the server executing this operation ' );
51+ }
52+
4253 /**
4354 * Thrown when explain is not supported by a server.
4455 *
Original file line number Diff line number Diff line change 1818namespace MongoDB \Operation ;
1919
2020use MongoDB \Driver \Command ;
21- use MongoDB \Driver \Exception \CommandException ;
2221use MongoDB \Driver \Exception \RuntimeException as DriverRuntimeException ;
2322use MongoDB \Driver \Server ;
2423use MongoDB \Driver \Session ;
@@ -219,7 +218,7 @@ private function executeCommand(Server $server)
219218 /* Drivers MUST manually raise an error if this option is specified
220219 * when creating an index on a pre 4.4 server. */
221220 if (! server_supports_feature ($ server , self ::$ wireVersionForCommitQuorum )) {
222- throw new CommandException ( ' Invalid field specified for createIndexes command: commitQuorum ' , 2 );
221+ throw UnsupportedException:: commitQuorumNotSupported ( );
223222 }
224223
225224 $ cmd ['commitQuorum ' ] = $ this ->options ['commitQuorum ' ];
Original file line number Diff line number Diff line change 33namespace MongoDB \Tests \Operation ;
44
55use InvalidArgumentException ;
6- use MongoDB \Driver \Exception \CommandException ;
76use MongoDB \Driver \Exception \RuntimeException ;
87use MongoDB \Driver \Server ;
8+ use MongoDB \Exception \UnsupportedException ;
99use MongoDB \Model \IndexInfo ;
1010use MongoDB \Operation \CreateIndexes ;
1111use MongoDB \Operation \ListIndexes ;
@@ -213,8 +213,8 @@ public function testCommitQuorumUnsupported()
213213 ['commitQuorum ' => 'majority ' ]
214214 );
215215
216- $ this ->expectException (CommandException ::class);
217- $ this ->expectExceptionMessage ('Invalid field specified for createIndexes command: commitQuorum ' );
216+ $ this ->expectException (UnsupportedException ::class);
217+ $ this ->expectExceptionMessage ('The "commitQuorum" option is not supported by the server executing this operation ' );
218218
219219 $ operation ->execute ($ this ->getPrimaryServer ());
220220 }
You can’t perform that action at this time.
0 commit comments