Class MongoException


public class MongoException extends IOException

A command MongoDB answered with ok: 0, or a write it reported failed.

getCode() is MongoDB's numeric error code (11000 for a duplicate key) and getCodeName() its name, when the server sent one.

  • Field Details

    • DUPLICATE_KEY

      public static final int DUPLICATE_KEY
      The code of a unique index violation.
      See Also:
  • Constructor Details

    • MongoException

      public MongoException(int code, String codeName, String message)
      A failure with a server code, its name (or null) and the message.
  • Method Details

    • getCode

      public int getCode()
      MongoDB's error code, or 0 when it sent none.
    • getCodeName

      public String getCodeName()
      The name of the code, such as DuplicateKey, or null.
    • isDuplicateKey

      public boolean isDuplicateKey()
      Whether this failure is a unique index violation.