As all the exceptions are extending the base Exception class, you can get the code with the getCode() method:
<?php
try {
$collection->insert($duplicate_document, array('safe' => true));
} catch (MongoCursorException $e) {
printf("Error code is %d.\n", $e->getCode();
exit(1);
}
The MongoCursorException class
Увод
Thrown by accessing a cursor incorrectly.
Синтаксис за класове
MongoCursorException
extends
MongoException
{
}
Loc d'Anterroches
18-Apr-2011 05:45
Jay Paroline
20-Aug-2010 11:05
Not sure if it's intentional but all the properties on CursorException (including code) are protected or private, so you will have to handle all CursorExceptions the same.
