Permalink
Browse files

Throw a proper message if cursor is of type Document.

  • Loading branch information...
1 parent 89a797c commit 2336ca3797f19afbf72f73f56f65cae15121d641 @lanwin lanwin committed Oct 7, 2010
Showing with 12 additions and 1 deletion.
  1. +12 −1 source/MongoDB/Cursor_1.cs
View
@@ -366,7 +366,18 @@ private void KillCursor(long cursorId)
Id = reply.CursorId;
if((reply.ResponseFlag & ResponseFlags.QueryFailure)!=0)
- throw new MongoException("Server returned query fail. Review server log to get the error.");
+ {
+ var error = "Review server log to get the error.";
+
+ if(reply.Documents.Length > 0)
+ {
+ var document = reply.Documents[0] as Document;
+ if(document != null)
+ error = Convert.ToString(document["$err"]);
+ }
+
+ throw new MongoException("The query failed on server. "+error);
+ }
return reply;
}

0 comments on commit 2336ca3

Please sign in to comment.