-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 4.1.1
-
Component/s: Documentation
-
None
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.