Skip to content

Commit e7582d4

Browse files
committed
remove isNamespaceNotFoundError()
1 parent b8fe817 commit e7582d4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

mongo/index_view.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ type IndexModel struct {
5151
Options *options.IndexOptionsBuilder
5252
}
5353

54-
func isNamespaceNotFoundError(err error) bool {
55-
var de driver.Error
56-
if errors.As(err, &de) {
57-
return de.Code == 26
58-
}
59-
return false
60-
}
61-
6254
// List executes a listIndexes command and returns a cursor over the indexes in the collection.
6355
//
6456
// The opts parameter can be used to specify options for this operation (see the options.ListIndexesOptions
@@ -121,7 +113,8 @@ func (iv IndexView) List(ctx context.Context, opts ...options.Lister[options.Lis
121113
if err != nil {
122114
// for namespaceNotFound errors, return an empty cursor and do not throw an error
123115
closeImplicitSession(sess)
124-
if isNamespaceNotFoundError(err) {
116+
var de driver.Error
117+
if errors.As(err, &de) && de.NamespaceNotFound() {
125118
return newEmptyCursor(), nil
126119
}
127120

0 commit comments

Comments
 (0)