public class

CommandResult

extends BasicDBObject
java.lang.Object
   ↳ java.util.AbstractMap<K, V>
     ↳ java.util.HashMap<K, V>
       ↳ java.util.LinkedHashMap<K, V>
         ↳ org.bson.BasicBSONObject
           ↳ com.mongodb.BasicDBObject
             ↳ com.mongodb.CommandResult

Class Overview

A simple wrapper for the result of getLastError() calls and other commands

Summary

Public Methods
String getErrorMessage()
gets the "errmsg" field which holds the error message
MongoException getException()
utility method to create an exception with the command name
ServerAddress getServerUsed()
boolean ok()
gets the "ok" field which is the result of the command
void throwOnError()
throws an exception containing the cmd name, in case the command failed, or the "err/code" information
[Expand]
Inherited Methods
From class com.mongodb.BasicDBObject
From class org.bson.BasicBSONObject
From class java.util.LinkedHashMap
From class java.util.HashMap
From class java.util.AbstractMap
From class java.lang.Object
From interface com.mongodb.DBObject
From interface java.util.Map
From interface org.bson.BSONObject

Public Methods

public String getErrorMessage ()

gets the "errmsg" field which holds the error message

Returns
  • The error message or null

public MongoException getException ()

utility method to create an exception with the command name

Returns
  • The mongo exception or null

public ServerAddress getServerUsed ()

public boolean ok ()

gets the "ok" field which is the result of the command

Returns
  • True if ok

public void throwOnError ()

throws an exception containing the cmd name, in case the command failed, or the "err/code" information