Package com.mongodb

Class CommandResult

All Implemented Interfaces:
DBObject, Serializable, Cloneable, Map<String,Object>, BSONObject, Bson

public class CommandResult extends BasicDBObject
A simple wrapper to hold the result of a command. All the fields from the response document have been added to this result.
See Also:
MongoDB documentation
Database Commands
  • Method Details

    • ok

      public boolean ok()
      Gets the "ok" field, which is whether this command executed correctly or not.
      true if the command executed without error.
    • getErrorMessage

      @Nullable public String getErrorMessage()
      Gets the error message associated with a failed command.
      The error message or null
    • getException

      @Nullable public MongoException getException()
      Utility method to create an exception from a failed command.
      The mongo exception, or null if the command was successful.
    • throwOnError

      public void throwOnError()
      Throws a CommandFailureException if the command failed. Otherwise, returns normally.
      MongoException - with the exception from the failed command
      See Also: