Skip to content

Commit

Permalink
GODRIVER-2939 Clarify IsDuplicateKeyError()'s docs (mongodb#1418)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Dale <9760375+matthewdale@users.noreply.github.com>
  • Loading branch information
ramitmittal and matthewdale authored Oct 18, 2023
1 parent 71f65e3 commit 9b3e3c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mongo/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func replaceErrors(err error) error {
return err
}

// IsDuplicateKeyError returns true if err is a duplicate key error.
// IsDuplicateKeyError returns true if err is a duplicate key error. For BulkWriteExceptions,
// IsDuplicateKeyError returns true if at least one of the errors is a duplicate key error.
func IsDuplicateKeyError(err error) bool {
if se := ServerError(nil); errors.As(err, &se) {
return se.HasErrorCode(11000) || // Duplicate key error.
Expand Down

0 comments on commit 9b3e3c4

Please sign in to comment.