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? :)