@@ -201,7 +201,7 @@ function bulkWrite(array $bulk, array $options = array()) { /* {{{ */
201
201
foreach ($ bulk as $ n => $ op ) {
202
202
foreach ($ op as $ opname => $ args ) {
203
203
if (!isset ($ args [0 ])) {
204
- throw \RuntimeException (sprintf ("Missing argument#1 for '%s' (operation#%d) " , $ opname , $ n ));
204
+ throw new \ InvalidArgumentException (sprintf ("Missing argument#1 for '%s' (operation#%d) " , $ opname , $ n ));
205
205
}
206
206
207
207
switch ($ opname ) {
@@ -211,7 +211,7 @@ function bulkWrite(array $bulk, array $options = array()) { /* {{{ */
211
211
212
212
case "updateMany " :
213
213
if (!isset ($ args [1 ])) {
214
- throw \RuntimeException (sprintf ("Missing argument#2 for '%s' (operation#%d) " , $ opname , $ n ));
214
+ throw new \ InvalidArgumentException (sprintf ("Missing argument#2 for '%s' (operation#%d) " , $ opname , $ n ));
215
215
}
216
216
$ options = array_merge ($ this ->getWriteOptions (), isset ($ args [2 ]) ? $ args [2 ] : array (), array ("limit " => 0 ));
217
217
@@ -220,23 +220,23 @@ function bulkWrite(array $bulk, array $options = array()) { /* {{{ */
220
220
221
221
case "updateOne " :
222
222
if (!isset ($ args [1 ])) {
223
- throw \RuntimeException (sprintf ("Missing argument#2 for '%s' (operation#%d) " , $ opname , $ n ));
223
+ throw new \ InvalidArgumentException (sprintf ("Missing argument#2 for '%s' (operation#%d) " , $ opname , $ n ));
224
224
}
225
225
$ options = array_merge ($ this ->getWriteOptions (), isset ($ args [2 ]) ? $ args [2 ] : array (), array ("limit " => 1 ));
226
226
if (key ($ args [1 ])[0 ] != '$ ' ) {
227
- throw new \RuntimeException ("First key in \$update must be a \$operator " );
227
+ throw new \InvalidArgumentException ("First key in \$update must be a \$operator " );
228
228
}
229
229
230
230
$ batch ->update ($ args [0 ], $ args [1 ], $ options );
231
231
break ;
232
232
233
233
case "replaceOne " :
234
234
if (!isset ($ args [1 ])) {
235
- throw \RuntimeException (sprintf ("Missing argument#2 for '%s' (operation#%d) " , $ opname , $ n ));
235
+ throw new \ InvalidArgumentException (sprintf ("Missing argument#2 for '%s' (operation#%d) " , $ opname , $ n ));
236
236
}
237
237
$ options = array_merge ($ this ->getWriteOptions (), isset ($ args [2 ]) ? $ args [2 ] : array (), array ("limit " => 1 ));
238
238
if (key ($ args [1 ])[0 ] == '$ ' ) {
239
- throw new \RuntimeException ("First key in \$update must NOT be a \$operator " );
239
+ throw new \InvalidArgumentException ("First key in \$update must NOT be a \$operator " );
240
240
}
241
241
242
242
$ batch ->update ($ args [0 ], $ args [1 ], $ options );
@@ -253,7 +253,7 @@ function bulkWrite(array $bulk, array $options = array()) { /* {{{ */
253
253
break ;
254
254
255
255
default :
256
- throw \RuntimeException (sprintf ("Unknown operation type called '%s' (operation#%d) " , $ opname , $ n ));
256
+ throw new \ InvalidArgumentException (sprintf ("Unknown operation type called '%s' (operation#%d) " , $ opname , $ n ));
257
257
}
258
258
}
259
259
}
@@ -297,15 +297,15 @@ protected function _update($filter, $update, $options) { /* {{{ */
297
297
} /* }}} */
298
298
function replaceOne (array $ filter , array $ update , array $ options = array ()) { /* {{{ */
299
299
if (key ($ update )[0 ] == '$ ' ) {
300
- throw new \RuntimeException ("First key in \$update must NOT be a \$operator " );
300
+ throw new \InvalidArgumentException ("First key in \$update must NOT be a \$operator " );
301
301
}
302
302
$ wr = $ this ->_update ($ filter , $ update , $ options );
303
303
304
304
return new UpdateResult ($ wr );
305
305
} /* }}} */
306
306
function updateOne (array $ filter , array $ update , array $ options = array ()) { /* {{{ */
307
307
if (key ($ update )[0 ] != '$ ' ) {
308
- throw new \RuntimeException ("First key in \$update must be a \$operator " );
308
+ throw new \InvalidArgumentException ("First key in \$update must be a \$operator " );
309
309
}
310
310
$ wr = $ this ->_update ($ filter , $ update , $ options );
311
311
@@ -503,7 +503,7 @@ function getFindOneAndDeleteOptions() { /* {{{ */
503
503
504
504
function findOneAndReplace (array $ filter , array $ replacement , array $ options = array ()) { /* {{{ */
505
505
if (key ($ replacement )[0 ] == '$ ' ) {
506
- throw new \RuntimeException ("First key in \$replacement must NOT be a \$operator " );
506
+ throw new \InvalidArgumentException ("First key in \$replacement must NOT be a \$operator " );
507
507
}
508
508
509
509
$ options = array_merge ($ this ->getFindOneAndReplaceOptions (), $ options );
@@ -566,7 +566,7 @@ function getFindOneAndReplaceOptions() { /* {{{ */
566
566
567
567
function findOneAndUpdate (array $ filter , array $ update , array $ options = array ()) { /* {{{ */
568
568
if (key ($ update )[0 ] != '$ ' ) {
569
- throw new \RuntimeException ("First key in \$update must be a \$operator " );
569
+ throw new \InvalidArgumentException ("First key in \$update must be a \$operator " );
570
570
}
571
571
572
572
$ options = array_merge ($ this ->getFindOneAndUpdateOptions (), $ options );
0 commit comments