Package com.mongodb

Class CommandResult

    • Method Detail

      • ok

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

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

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

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