2

The MongoDB is down, but I can't capture the error description,the "error" argument in mongoc_collection_insert () is empty. This happened, when I use called mongoc_client_get_server_status() in codes.

While, the collectionerror can be shown without calling function mongoc_client_get_server_status().

I am not sure if there is a small bug in MongoDB, or something wrong in my codes.

if (!mongoc_client_get_server_status(client,NULL,NULL,&error)) {
        printf("Connection Error Happens:%s\n",error.message);
        mongoc_client_destroy (client);
        mongoc_cleanup ();
        return 0;
    } 
    collection = mongoc_client_get_collection (client, "gcctest", "facebook");
    if (!mongoc_collection_stats(collection,NULL,reply,&error)) {
        printf("Collection error:%s\n",error.message);
    }   
    if (!mongoc_collection_insert (collection, MONGOC_INSERT_NONE, doc, NULL, &error)) {
        printf("INSET ERROR:%s\n",error.message);
    } else
        printf("Insert successfully\n");
Z.Chloe
  • 21
  • 2

0 Answers0