[CSHARP-463] Unexpected and not documented exception in MongoDatabase.CreateCollection(String, IMongoCollectionOptions) Created: 03/May/12 Updated: 02/Apr/15 Resolved: 11/Jun/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.4.2 |
| Fix Version/s: | 1.5 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Roman Kuzmin | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
I am trying to create a collection which already exists (a capped one, if this I propose either to document this exception (it is not) or, better, to not |
| Comments |
| Comment by Robert Stam [ 11/Jun/12 ] |
|
The general rule with all commands is that the driver throws an exception when the server returns { ok : 0 }as part of the result of the command. CreateCollection follows this rule to the letter. DropCollection follows it with one exception: if the server returns { ok : 0 }with an error message of "ns not found" the error is considered benign and ignored. All the drivers do this. Really the server should not be returning an error in this case, but apparently the server is not going to be changed. You don't need to check the OK property of a CommandResult. If no exception was thrown the command succeeded. |