[JAVA-3919] Documentation of DuplicateKeyException should be clarified Created: 22/Dec/20  Updated: 28/Oct/23  Resolved: 17/Mar/21

Status: Closed
Project: Java Driver
Component/s: Documentation
Affects Version/s: 4.1.1
Fix Version/s: 4.3.0

Type: Improvement Priority: Major - P3
Reporter: Marc Knaup Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The documentation of `DuplicateKeyException` states:

> Subclass of WriteConcernException representing a duplicate key exception

And `WriteConcernException` in turn:

> An exception representing an error reported due to a write failure.

This is confusing. From the documentation one has to assume that `DuplicateKeyException` is thrown in case a duplicate key is encountered during a write operation.
What's actually thrown is a `MongoCommandException` with `ErrorCategory.fromErrorCode(e.code) == ErrorCategory.DUPLICATE_KEY`.

The documentation of `DuplicateKeyException` should be amended to clarify that it's not actually used (in certain situations) in this case counter to what the developer may expect or assume.



 Comments   
Comment by Githook User [ 17/Mar/21 ]

Author:

{'name': 'jyemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Document DuplicateKeyException and WriteConcernException are effectively deprecated

JAVA-3919
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/279782f45995683c88f3d28d76bb246c4bd02daf

Comment by Esha Bhargava [ 04/Jan/21 ]

marc@knaup.io Thank you for reporting this issue! We have scheduled, and will work on it soon.

Generated at Thu Feb 08 09:00:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.