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.