Skip to content

Commit 67ed9ee

Browse files
authored
PLM184: Check if error is not NamespaceExists (#127)
1 parent 1cb0b98 commit 67ed9ee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

plm/catalog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func (c *Catalog) doCreateCollection(
227227

228228
return errors.Wrapf(err, "create collection %s.%s", db, coll)
229229
})
230-
if err != nil {
230+
if err != nil && !topo.IsNamespaceExists(err) {
231231
return err //nolint:wrapcheck
232232
}
233233

topo/errors.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func IsNamespaceNotFound(err error) bool {
2323
return isMongoCommandError(err, "NamespaceNotFound")
2424
}
2525

26+
func IsNamespaceExists(err error) bool {
27+
return isMongoCommandError(err, "NamespaceExists")
28+
}
29+
2630
// IsCollectionDropped checks if the error is caused by a collection being dropped.
2731
func IsCollectionDropped(err error) bool {
2832
var cmdErr mongo.CommandError

0 commit comments

Comments
 (0)