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()
39
39
return new static ('Collations are not supported by the server executing this operation ' );
40
40
}
41
41
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
+
42
53
/**
43
54
* Thrown when explain is not supported by a server.
44
55
*
Original file line number Diff line number Diff line change 18
18
namespace MongoDB \Operation ;
19
19
20
20
use MongoDB \Driver \Command ;
21
- use MongoDB \Driver \Exception \CommandException ;
22
21
use MongoDB \Driver \Exception \RuntimeException as DriverRuntimeException ;
23
22
use MongoDB \Driver \Server ;
24
23
use MongoDB \Driver \Session ;
@@ -219,7 +218,7 @@ private function executeCommand(Server $server)
219
218
/* Drivers MUST manually raise an error if this option is specified
220
219
* when creating an index on a pre 4.4 server. */
221
220
if (! server_supports_feature ($ server , self ::$ wireVersionForCommitQuorum )) {
222
- throw new CommandException ( ' Invalid field specified for createIndexes command: commitQuorum ' , 2 );
221
+ throw UnsupportedException:: commitQuorumNotSupported ( );
223
222
}
224
223
225
224
$ cmd ['commitQuorum ' ] = $ this ->options ['commitQuorum ' ];
Original file line number Diff line number Diff line change 3
3
namespace MongoDB \Tests \Operation ;
4
4
5
5
use InvalidArgumentException ;
6
- use MongoDB \Driver \Exception \CommandException ;
7
6
use MongoDB \Driver \Exception \RuntimeException ;
8
7
use MongoDB \Driver \Server ;
8
+ use MongoDB \Exception \UnsupportedException ;
9
9
use MongoDB \Model \IndexInfo ;
10
10
use MongoDB \Operation \CreateIndexes ;
11
11
use MongoDB \Operation \ListIndexes ;
@@ -213,8 +213,8 @@ public function testCommitQuorumUnsupported()
213
213
['commitQuorum ' => 'majority ' ]
214
214
);
215
215
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 ' );
218
218
219
219
$ operation ->execute ($ this ->getPrimaryServer ());
220
220
}
You can’t perform that action at this time.
0 commit comments