[SERVER-3387] getLastErrorDetailed does not report an error Created: 07/Jul/11 Updated: 29/Aug/11 Resolved: 07/Jul/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 1.8.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Alexey Guseynov | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
linux, ubuntu lucyd. |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
Request: , "update" : { "$set" : { < SOME FIELDS HERE > } }, "new" : true, "upsert" : false } As far as mongo C++ driver does not throw exceptions and every command has it's own way to report errors I prefer to use getLastErrorDetailed() where possible. But unfortunately it reports that there was no error: { "n" : 0, "connectionId" : 88, "err" : null, "ok" : 1 }Please, make C++ driver to report error is only one way. It would especially good if it would be exceptions. I'm really frustrated to find out that one part of my application has crashed with very strange error because there is another one way to report error which my magic checker does not know about. |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 07/Jul/11 ] |
|
I was thinking of this command for running findAndModify Updated the docs for getLastError |
| Comment by Alexey Guseynov [ 07/Jul/11 ] |
|
> For commands (findAndModify etc...) the method returns true or false if succeeded or not. Actually, it does not return true or false. It returns BSON object which has double precision flag. It is if you would try to check it for beeng true or false you would get "wrong BSON type" exception. > The only things you need getLastError for are insert/update/delete. Both 1.9.0 and 1.8.1 API documentation say: So I does not work as designed. Please reopen the bugreport or change documentation to reflect that sometimes getLastError returns last error and sometimes it doesn't. |
| Comment by Eliot Horowitz (Inactive) [ 07/Jul/11 ] |
|
This is correct for normal mode. |
| Comment by Eliot Horowitz (Inactive) [ 07/Jul/11 ] |
|
For commands (findAndModify etc...) the method returns true or false if succeeded or not. The only things you need getLastError for are insert/update/delete. We're going a "safe" mode to the driver which will use exceptions: |