0

I have a relatively simple example of making an oid with mongocxx driver. It is as follows:

try {
// assetId is const UInt8 *
bsoncxx::oid id = bsoncxx::oid{std::string((const char *)assetId)};

} catch (const std::exception& xcp) {
    std::cout << "-------------" << std::endl;
    std::cout << "connection failed: " << xcp.what() << "\n";
    std::cout << "-------------" << std::endl;
    return kDRMSKDServerDBAssetIDErr;
}

However I keep getting: unknown bsoncxx error code

I have no idea what I'm doing wrong.

acm
  • 12,183
  • 5
  • 39
  • 68
Dr.Knowitall
  • 10,080
  • 23
  • 82
  • 133
  • When posting questions about errors, please include the *complete* error in your question. If it's build errors copy-paste it, as is and without editing, as text into the question body. – Some programmer dude Oct 17 '16 at 17:52
  • Thats the problem, this is the complete error – Dr.Knowitall Oct 17 '16 at 17:53
  • 1
    Without an [SSCCE](http://sscce.org) it's hard to determine the exact problem. However, most likely the assetID isn't a valid hexadecimal object ID. See the [docs](https://mongodb.github.io/mongo-cxx-driver/api/current/classbsoncxx_1_1oid.html#a48be4a43ece04c4434342c2ebb937113) for it. For reference, what version of mongocxx and libmongoc are you using? – xdg Oct 18 '16 at 14:15
  • I figured it out, but apparently a poorly crafted oid will result in that error. They should fix their error messages. – Dr.Knowitall Oct 18 '16 at 18:49

1 Answers1

0

A poorly crafted OID will result in this error message, so beware of their poorly crafted error messages.

Dr.Knowitall
  • 10,080
  • 23
  • 82
  • 133
  • It's been [patched in the repo](https://github.com/mongodb/mongo-cxx-driver/commit/340df1420869e647929fa00e295af0e395723d74) and will be in a future release. If (when) you find other poorly crafted error messages, please let us know and we'll fix them. – xdg Oct 18 '16 at 20:00