Skip to content

Commit 8dd1594

Browse files
committed
cursor: be more helpful with error output in cursor query stage.
1 parent eeb7a82 commit 8dd1594

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/mongoc/mongoc-cursor.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,22 @@ _mongoc_cursor_query (mongoc_cursor_t *cursor)
503503
goto failure;
504504
}
505505

506-
if ((cursor->rpc.header.opcode != MONGOC_OPCODE_REPLY) ||
507-
(cursor->rpc.header.response_to != request_id)) {
508-
bson_set_error(&cursor->error,
509-
MONGOC_ERROR_PROTOCOL,
510-
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
511-
"A reply to an invalid request id was received.");
512-
goto failure;
506+
if (cursor->rpc.header.opcode != MONGOC_OPCODE_REPLY) {
507+
bson_set_error (&cursor->error,
508+
MONGOC_ERROR_PROTOCOL,
509+
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
510+
"Invalid opcode. Expected %d, got %d.",
511+
MONGOC_OPCODE_REPLY, cursor->rpc.header.opcode);
512+
GOTO (failure);
513+
}
514+
515+
if (cursor->rpc.header.response_to != request_id) {
516+
bson_set_error (&cursor->error,
517+
MONGOC_ERROR_PROTOCOL,
518+
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
519+
"Invalid response_to. Expected %d, got %d.",
520+
request_id, cursor->rpc.header.response_to);
521+
GOTO (failure);
513522
}
514523

515524
if (_mongoc_cursor_unwrap_failure(cursor)) {

0 commit comments

Comments
 (0)