protected void marshall(BsonDocumentBuilder builder) { if (errorDesc == null) { assert error.equals(ErrorCode.OK); builder.appendNull(ERR_FIELD_NAME); } else { builder.append(ERR_FIELD_NAME, errorDesc); builder.append(CODE_FIELD_NAME, error.getErrorCode()); } builder.append(N_FIELD_NAME, getN()); if (replInfo != null) { replInfo.marshall(builder); } if (shardInfo != null) { shardInfo.marshall(builder); } }
public SimpleWriteOpResult( @Nonnull ErrorCode error, @Nullable ReplicationInformation replInfo, @Nullable ShardingInformation shardInfo, @Nonnull OpTime optime, Object... args) { this.error = error; this.replInfo = replInfo; this.shardInfo = shardInfo; if (error.equals(ErrorCode.OK)) { if (args.length != 0) { throw new IllegalArgumentException( "Error description must be " + "null when the given error code is OK"); } this.errorDesc = null; } else { errorDesc = MessageFormat.format(error.getErrorMessage(), args); } this.optime = optime; }
public SimpleWriteOpResult( @Nonnull ErrorCode error, @Nullable String errorDesc, @Nullable ReplicationInformation replInfo, @Nullable ShardingInformation shardInfo, @Nonnull OpTime optime) { this.error = error; this.replInfo = replInfo; this.shardInfo = shardInfo; if (errorDesc != null && error.equals(ErrorCode.OK)) { throw new IllegalArgumentException( "Error description must be " + "null when the given error code is OK"); } this.errorDesc = errorDesc; this.optime = optime; }
@Override public boolean errorOcurred() { return !error.equals(ErrorCode.OK); }