- 
    Type:
New Feature
 - 
    Resolution: Won't Fix
 - 
    Priority:
Major - P3
 - 
    None
 - 
    Affects Version/s: None
 - 
    Component/s: None
 - 
    None
 
- 
        None
 
- 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 
I propose we introduce a new DuplicateKeyException if we can detect the relevant error code in a BulkWriteException thrown from Server::executeBulkWrite(). We should be able to do this for non-ambiguous cases, such as single-statement writes (e.g. insertOne, updateOne).
It may be feasible for multi-statement writes (e.g. insertMany, bulkWrite) if all errors in the BulkWriteException can be classified as a DuplicateKeyException. If there are various write errors in the bulk write exception (possible if ordered is false), we should leave the exception as-is so that users can make sense of it. Before handling the multi-statement case, let's consult with other drivers to see if there is prior art.
- depends on
 - 
                    
CDRIVER-709 Define mongoc_error_code_t value for "duplicate key error"
-         
 - Closed
 
 -         
 - 
                    
PHPC-791 Upgrade libbson and libmongoc to 1.5.0
-         
 - Closed
 
 -         
 
- duplicates
 - 
                    
PHPLIB-203 Allow single-write operations to throw a DuplicateKeyException
-         
 - Closed
 
 -         
 
- is related to
 - 
                    
PHPC-1434 Add index name as a separate field on duplicate key error object
-         
 - Closed
 
 -         
 
- links to