Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static String message(
@Nullable final Map<Integer, WriteError> writeErrors,
@Nullable final ClientBulkWriteResult partialResult,
final ServerAddress serverAddress) {
return "Client-level bulk write operation error on server " + serverAddress + "."
return "Client-level bulk write operation error on MongoDB server " + serverAddress + "."
+ (error == null ? "" : " Top-level error: " + error + ".")
+ (writeErrors == null || writeErrors.isEmpty() ? "" : " Write errors: " + writeErrors + ".")
+ (writeConcernErrors == null || writeConcernErrors.isEmpty() ? "" : " Write concern errors: " + writeConcernErrors + ".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class MongoBulkWriteException extends MongoServerException {
public MongoBulkWriteException(final BulkWriteResult writeResult, final List<BulkWriteError> writeErrors,
@Nullable final WriteConcernError writeConcernError, final ServerAddress serverAddress,
final Set<String> errorLabels) {
super("Bulk write operation error on server " + serverAddress + ". "
super("Bulk write operation error on MongoDB server " + serverAddress + ". "
+ (writeErrors.isEmpty() ? "" : "Write errors: " + writeErrors + ". ")
+ (writeConcernError == null ? "" : "Write concern error: " + writeConcernError + ". "), serverAddress);
this.writeResult = writeResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class MongoCommandException extends MongoServerException {
*/
public MongoCommandException(final BsonDocument response, final ServerAddress address) {
super(extractErrorCode(response), extractErrorCodeName(response),
format("Command failed with error %s: '%s' on server %s. The full response is %s", extractErrorCodeAndName(response),
format("Command execution failed on MongoDB server with error %s: '%s' on server %s. The full response is %s", extractErrorCodeAndName(response),
extractErrorMessage(response), address, getResponseAsJson(response)), address);
this.response = response;
addLabels(extractErrorLabelsAsBson(response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MongoWriteException(final WriteError error, final ServerAddress serverAdd
* @since 5.0
*/
public MongoWriteException(final WriteError error, final ServerAddress serverAddress, final Collection<String> errorLabels) {
super(error.getCode(), "Write operation error on server " + serverAddress + ". Write error: " + error + ".", serverAddress);
super(error.getCode(), "Write operation error on MongoDB server " + serverAddress + ". Write error: " + error + ".", serverAddress);
this.error = error;
addLabels(errorLabels);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ class MongoCommandExceptionSpecification extends Specification {
new MongoCommandException(new BsonDocument('ok', BsonBoolean.FALSE).append('code', new BsonInt32(26))
.append('codeName', new BsonString('TimeoutError')).append('errmsg', new BsonString('the error message')),
new ServerAddress())
.getMessage() == 'Command failed with error 26 (TimeoutError): \'the error message\' on server 127.0.0.1:27017. ' +
'The full response is {"ok": false, "code": 26, "codeName": "TimeoutError", "errmsg": "the error message"}'
.getMessage() == 'Command execution failed on MongoDB server with error 26 (TimeoutError): \'the error message\' ' +
'on server 127.0.0.1:27017. The full response is {"ok": false, "code": 26, "codeName": "TimeoutError", ' +
'"errmsg": "the error message"}'
new MongoCommandException(new BsonDocument('ok', BsonBoolean.FALSE).append('code', new BsonInt32(26))
.append('errmsg', new BsonString('the error message')), new ServerAddress())
.getMessage() == 'Command failed with error 26: \'the error message\' on server 127.0.0.1:27017. ' +
'The full response is {"ok": false, "code": 26, "errmsg": "the error message"}'
.getMessage() == 'Command execution failed on MongoDB server with error 26: \'the error message\' ' +
'on server 127.0.0.1:27017. The full response is {"ok": false, "code": 26, "errmsg": "the error message"}'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void testExceptionProperties() {
WriteError writeError = new WriteError(11000, "Duplicate key", new BsonDocument("x", new BsonInt32(1)));
MongoWriteException e = new MongoWriteException(writeError, new ServerAddress("host1"), Collections.emptySet());

assertEquals("Write operation error on server host1:27017. Write error: WriteError{code=11000, message='Duplicate key', "
assertEquals("Write operation error on MongoDB server host1:27017. Write error: WriteError{code=11000, message='Duplicate key', "
+ "details={\"x\": 1}}.",
e.getMessage());
assertEquals(writeError.getCode(), e.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class BulkWriteException extends MongoServerException {
*/
BulkWriteException(final BulkWriteResult writeResult, final List<BulkWriteError> writeErrors,
@Nullable final WriteConcernError writeConcernError, final ServerAddress serverAddress) {
super("Bulk write operation error on server " + serverAddress + ". "
super("Bulk write operation error on MongoDB server " + serverAddress + ". "
+ (writeErrors.isEmpty() ? "" : "Write errors: " + writeErrors + ". ")
+ (writeConcernError == null ? "" : "Write concern error: " + writeConcernError + ". "), serverAddress);
this.writeResult = writeResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public void test3p2AuthFailsWithoutCachedToken() {
MongoClientSettings clientSettings = createSettings(callback);
try (MongoClient mongoClient = createMongoClient(clientSettings)) {
assertCause(MongoCommandException.class,
"Command failed with error 18 (AuthenticationFailed):",
"Command execution failed on MongoDB server with error 18 (AuthenticationFailed):",
() -> performFind(mongoClient));
}
}
Expand All @@ -424,7 +424,7 @@ public void test3p3UnexpectedErrorDoesNotClearCache() {
try (MongoClient mongoClient = createMongoClient(clientSettings)) {
failCommand(20, 1, "saslStart");
assertCause(MongoCommandException.class,
"Command failed with error 20",
"Command execution failed on MongoDB server with error 20",
() -> performFind(mongoClient));

assertEquals(Arrays.asList(
Expand Down Expand Up @@ -471,7 +471,7 @@ public void test4p2ReadCommandsFailIfReauthenticationFails() {
performFind(mongoClient);
failCommand(391, 1, "find");
assertCause(MongoCommandException.class,
"Command failed with error 18",
"Command execution failed on MongoDB server with error 18",
() -> performFind(mongoClient));
}
assertEquals(2, wrappedCallback.invocations.get());
Expand All @@ -492,7 +492,7 @@ public void test4p3WriteCommandsFailIfReauthenticationFails() {
performInsert(mongoClient);
failCommand(391, 1, "insert");
assertCause(MongoCommandException.class,
"Command failed with error 18",
"Command execution failed on MongoDB server with error 18",
() -> performInsert(mongoClient));
}
assertEquals(2, wrappedCallback.invocations.get());
Expand Down Expand Up @@ -740,7 +740,7 @@ public void testh3p2NoSpecAuthIfNoCachedToken() {
TestCommandListener commandListener = new TestCommandListener(listener);
assertFindFails(createHumanSettings(createHumanCallback(), commandListener),
MongoCommandException.class,
"Command failed with error 18");
"Command execution failed on MongoDB server with error 18");
assertEquals(Arrays.asList(
"isMaster started",
"isMaster succeeded",
Expand Down Expand Up @@ -833,7 +833,7 @@ public void testh4p4Fails() {
assertEquals(1, callback1.getInvocations());
failCommand(391, 1, "find");
assertCause(MongoCommandException.class,
"Command failed with error 18",
"Command execution failed on MongoDB server with error 18",
() -> performFind(mongoClient));
assertEquals(3, callback1.getInvocations());
}
Expand Down