Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-898

DBClientBase::insert() error handling

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • legacy-1.0.6
    • API
    • None
    • Linux xxx 2.6.32-573.18.1.el6.x86_64 #1 SMP Wed Jan 6 11:20:49 EST 2016 x86_64 x86_64 x86_64 GNU/Linux

    Description

      I am calling DBClientBase::insert(), I am trying to add error handling code.
      From the implementation:

      2043 // prefer using the bulk API for this
      2044 void DBClientBase::insert(const string& ns,
      2045                           const vector<BSONObj>& v,
      2046                           int flags,
      2047                           const WriteConcern* wc) {
      2048     ScopedWriteOperations inserts;
      2049 
      2050     vector<BSONObj>::const_iterator bsonObjIter;
      2051     for (bsonObjIter = v.begin(); bsonObjIter != v.end(); ++bsonObjIter) {
      2052         uassert(0,
      2053                 "document to be inserted exceeds maxBsonObjectSize",
      2054                 (*bsonObjIter).objsize() <= getMaxBsonObjectSize());
      2055         inserts.enqueue(new InsertWriteOperation(*bsonObjIter));
      2056     }
      2057 
      2058     bool ordered = !(flags & InsertOption_ContinueOnError);
      2059 
      2060     WriteResult writeResult;
      2061     _write(ns, inserts.ops, ordered, wc, &writeResult);
      2062 }
      

      In line 2060 - 2061, it looks the errorCode is written in writeResult? If so, it is not passed back to the caller.
      How would the caller do the error handling in this case? Does that mean I have to modify this API?
      Please let me know if I miss something.
      Thanks!
      Judy

      Attachments

        Activity

          People

            Unassigned Unassigned
            Judy.Han Judy Han [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: