Am 24.01.2013 13:29, schrieb Dicebot:

On Wed, 23 Jan 2013 16:17:13 GMT, Sönke Ludwig wrote:

On Tue, 22 Jan 2013 20:37:24 GMT, Dicebot wrote:

Intro: I want to improve MongoException class to use detailed error information from mongo. I.e.
I want to be able in server code to ignore only errors about insert duplicates (with index ofc),
but not any others. It looks like db.getLastErrorObj() provides enough information for making a
lot of sane choices (and probably building a better exception hierarchy).

However, from the first glance I hardly understood how new command can be translated from mongo
shell to driver BSON. vibe.db.mongo.db has getLastError but that beast is some strange builtin
(documenation link broken) and provides less info, specifically does not provide numeric error code.

Can someone more experience with mongo show me the way? :)

I've taken a look and as far as I can tell it's actually the same command on the protocol level.
If you print the contents of res in connection.d line 278, it has, among others, the fields
"err" and "code". MongoDB.getLastError should yield exactly the same output as it triggers the
same command.

Ok, thanks, I was mistaken thinking getLastError should match db.getLastError in mongo shell. Won't
you mind if I add some docs for it?

Definitely not. It would also probably make more sense to let it return a struct instead of Bson. I
have no idea when it was added, but it surely looks like it was just a quick addition instead of
being thought through.