Permalink
Browse files

Throw if cursor returns a query failure. Currently without message.

  • Loading branch information...
1 parent 725088f commit 89a797c9bf1e70f9e7587a03e8042153cd43aa4e @lanwin lanwin committed Oct 7, 2010
Showing with 11 additions and 2 deletions.
  1. +7 −1 source/MongoDB.Tests/IntegrationTests/TestCursor.cs
  2. +4 −1 source/MongoDB/Cursor_1.cs
@@ -27,7 +27,6 @@ public override void OnInit()
var properties = Enumerable.Range(1, 500).ToDictionary(x => x.ToString(), x => (object)x).ToArray();
var largereads = DB["largereads"];
largereads.Insert(Enumerable.Range(1, 3000).Select(i => new Document(properties)));
-
}
[Test]
@@ -50,6 +49,13 @@ public void TestCanLimitWithLargeResultSet()
}
[Test]
+ [ExpectedException(typeof(MongoException))]
+ public void TestThrowsAnExceptionIfServerReturnsAQueryFailure()
+ {
+ DB["largereads"].FindAll().Sort("j").Documents.Any();
+ }
+
+ [Test]
public void TestCanReadAndKillCursor()
{
var c = (Cursor)DB["reads"].FindAll();
@@ -362,8 +362,11 @@ private void KillCursor(long cursorId)
{
var reply = _connection.SendTwoWayMessage<TReply>(message, readerSettings, _databaseName);
-
+
Id = reply.CursorId;
+
+ if((reply.ResponseFlag & ResponseFlags.QueryFailure)!=0)
+ throw new MongoException("Server returned query fail. Review server log to get the error.");
return reply;
}

0 comments on commit 89a797c

Please sign in to comment.