[CSHARP-951] KeyNotFoundException on accessing GetLastErrorResult.DocumentsAffected property Created: 13/Apr/14  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Closed
Project: C# Driver
Component/s: API, Error Handling
Affects Version/s: 1.9
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Pantyushin Roman Assignee: Unassigned
Resolution: Done Votes: 0
Labels: documentsAffected, driver, getLastError
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 2.6



 Description   

            var coll = new MongoClient("mongodb://localhost:27017/").GetServer().GetDatabase("driverBug").GetCollection("coll0");
            coll.Drop();
            coll.CreateIndex(IndexKeys.Ascending("fld0"));
            try
            {
                coll.CreateIndex(IndexKeys.Ascending("fld0"), IndexOptions.SetSparse(true));
            }
            catch (WriteConcernException ex)
            {
                Console.WriteLine(ex.WriteConcernResult.DocumentsAffected); // XXX
            }

"KeyNotFoundException" at line "XXX". I assume that "DocumentsAffected" is not relevant to index creation errors so "InvalidOperationException" or "NotSupportedException" should be thrown in this case. Or maybe return zero, but not "KeyNotFoundException".


Generated at Wed Feb 07 21:38:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.