Package com.mongodb

Class MongoCommandException

    • Constructor Detail

      • MongoCommandException

        public MongoCommandException​(BsonDocument response,
                                     ServerAddress address)
        Construct a new instance with the CommandResult from a failed command
        Parameters:
        response - the command response
        address - the address of the server that generated the response
    • Method Detail

      • getErrorCode

        public int getErrorCode​()
        Gets the error code associated with the command failure.
        Returns:
        the error code
      • getErrorCodeName

        public String getErrorCodeName​()
        Gets the name associated with the error code.
        Returns:
        the error code name, which may be the empty string
        Since:
        3.8
        Since server release
        3.4
      • getErrorMessage

        public String getErrorMessage​()
        Gets the error message associated with the command failure.
        Returns:
        the error message
      • getResponse

        public BsonDocument getResponse​()
        For internal use only.
        Returns:
        the full response to the command failure.