code: function(error) {
    if (error instanceof Error) return error;
  
    var msg = error.err || error.errmsg || error.errMessage || error;
    var e = MongoError.create({ message: msg, driver: true });
  
    // Get all object keys
    var keys = typeof error === 'object' ? Object.keys(error) : [];
  
    for (var i = 0; i < keys.length; i++) {
      try {
        e[keys[i]] = error[keys[i]];
      } catch (err) {
        // continue
      }
    }
  
    return e;
  }
docs: Wrap a Mongo error document in an Error instance
  @ignore
  @api private