Exceptions
PHP Manual

The MongoCursorException class

Introduction

Caused by accessing a cursor incorrectly or a error receiving a reply.

If there is an error receiving a reply, there will be a more specific error message to help diagnose the problem. As it is a bit programmatically awkward to parse an exception message, there is also an error code associated with each cause of the exception.

  • cannot modify cursor after beginning iteration

    Code: 0

    You are calling a method that sets up the query after executing the query. Reset the cursor and try again.

  • Various send errors

    Code: 1

    Could not send the query to the database. Make sure the database is still up and the network is okay.

  • cursor not found

    Code: 2

    The driver was trying to fetch more results from the database, but the database did not have a record of the query. This usually means that the cursor timed out on the server side: after a few minutes of inactivity, the database will kill a cursor (see MongoCursor::immortal() for information on preventing this).

  • Various database errors

    Code: 4

    The database errored out on the query. The error message should be fairly self-explanatory, but you can check the database log for details.

  • couldn't get response header

    Code: 3

    The driver could not fetch a reply header from the database, so it gave up. Check if the database is still up and the network is connected and try the query again.

  • no db response

    Code: 5

    This may not even be an error, for example, the database command "shutdown" returns no response. However, if you were expecting a response, this means the database didn't give one.

  • no db response

    Code: 5

  • bad response length: %d, max: %d, did the db assert?

    Code: 6

    This means that the database said that its response was greater than 4Mb or less than 0. Generally, a number greater than 5Mb should be reported to the developers as a potential database bug (max response length is 4Mb). A response of less than 0 often means a database assertion occured.

  • incomplete header/response

    Code: 7

    Highly unusual. Occurs if the database response started out correctly, but broke off in the middle. Probably indicates a network problem.

  • error getting database response: errstr

    WSA error getting database response: errstr

    "errstr" is an io error reported directly from the C socket subsystem. On Windows, the error message is prefixed with "WSA".

  • error getting database response: <various>

    Code: 8

    Something went wrong at the socket layer. This will return the error message from the C socket library.

  • couldn't find a response

    Code: 9

    If the response was cached and now cannot be located.

  • various

    Code: 10

    No code given by the database.

  • E11000 duplicate key error index: foo.bar.$X dup key: { /* ... */ }

    Code: 11000

    Database error for duplicate keys.

Class synopsis

extends MongoException {
}

Exceptions
PHP Manual