Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure write error is included in exception message #724

Merged
merged 3 commits into from
Jun 8, 2021

Conversation

jyemin
Copy link
Contributor

@jyemin jyemin commented Jun 3, 2021

Implement new CRUD specification prose test for write error details

JAVA-3993

Implement new CRUD specification prose test for write error details

JAVA-3993
@jyemin jyemin self-assigned this Jun 3, 2021
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;

// See https://github.com/mongodb/specifications/tree/master/source/change-streams/tests/README.rst#prose-tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was copy pasta-d from elsewhere.

/**
* See https://github.com/mongodb/specifications/blob/master/source/crud/tests/README.rst#prose-tests
*/
public class CrudProseTest extends DatabaseTestCase {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed class to indicate the spec from which the prose tests came

@@ -33,7 +33,7 @@
* @param serverAddress the server address
*/
public MongoWriteException(final WriteError error, final ServerAddress serverAddress) {
super(error.getCode(), error.getMessage(), serverAddress);
super("Write operation error on server " + serverAddress + ". Write error: " + error + ". ", serverAddress);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensures that the whole write error, including details, will show up as part of the exception message. This matches the behavior of MongoBulkWriteException.

@jyemin jyemin requested review from stIncMale and rozza June 3, 2021 19:55
@jyemin jyemin marked this pull request as draft June 3, 2021 21:47
@jyemin
Copy link
Contributor Author

jyemin commented Jun 3, 2021

Converted to draft as tests are failing.

@jyemin jyemin requested a review from stIncMale June 4, 2021 14:22
@jyemin jyemin marked this pull request as ready for review June 4, 2021 14:23
Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jyemin jyemin merged commit a493a26 into mongodb:master Jun 8, 2021
@jyemin jyemin deleted the j3993 branch June 8, 2021 15:24
jyemin added a commit to jyemin/mongo-java-driver that referenced this pull request Jun 8, 2021
Implement new CRUD specification prose test for write error details

JAVA-3993
ispringer pushed a commit to evergage/mongo-java-driver that referenced this pull request May 16, 2023
Implement new CRUD specification prose test for write error details

JAVA-3993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants