driver-legacy/src/main/com/mongodb/CommandResult.java
@Nullable
    public String getErrorMessage() {
        Object foo = get("errmsg");
        if (foo == null) {
            return null;
        }
        return foo.toString();
    }
@Nullable
    public String getErrorMessage() {
        Object foo = get("errmsg");
        if (foo == null) {
            return null;
        }
        return foo.toString();
    }
Gets the error message associated with a failed command.

@return The error message or null