Skip to content

Commit

Permalink
db_mongodb: add error logger for failed query
Browse files Browse the repository at this point in the history
(cherry picked from commit 2a5d66f)
(cherry picked from commit 63c93af)
  • Loading branch information
kelchy authored and miconda committed Apr 25, 2018
1 parent b017462 commit fac42c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/db_mongodb/mongodb_dbase.c
Expand Up @@ -753,6 +753,7 @@ static int db_mongodb_store_result(const db1_con_t* _h, db1_res_t** _r)
km_mongodb_con_t *mgcon;
db_mongodb_result_t *mgres;
const bson_t *itdoc;
bson_error_t error;

mgcon = MONGODB_CON(_h);
if(!_r) {
Expand All @@ -777,7 +778,11 @@ static int db_mongodb_store_result(const db1_con_t* _h, db1_res_t** _r)
if(!mongoc_cursor_more (mgres->cursor)
|| !mongoc_cursor_next (mgres->cursor, &itdoc)
|| !itdoc) {
LM_DBG("no result from mongodb\n");
if (mongoc_cursor_error (mgres->cursor, &error)) {
LM_DBG("An error occurred: %s\n", error.message);
} else {
LM_DBG("no result from mongodb\n");
}
return 0;
}
/* first document linked internally in result to get columns */
Expand Down

0 comments on commit fac42c3

Please sign in to comment.